-
Notifications
You must be signed in to change notification settings - Fork 109
Add AIMLAPI integration documentation and logo #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| layout: integration | ||
| name: AIMLAPI | ||
| description: Call AIMLAPI's OpenAI-compatible chat models from Haystack pipelines and agents. | ||
| authors: | ||
| - name: AI/ML API | ||
| socials: | ||
| github: aimlapi | ||
| twitter: aimlapi | ||
| linkedin: https://www.linkedin.com/company/aimlapi/ | ||
| - name: deepset | ||
| socials: | ||
| github: deepset-ai | ||
| twitter: deepset_ai | ||
| linkedin: https://www.linkedin.com/company/deepset-ai/ | ||
| pypi: https://pypi.org/project/aimlapi-haystack | ||
| repo: https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/aimlapi | ||
| report_issue: https://github.com/deepset-ai/haystack-core-integrations/issues | ||
| logo: /logos/aimlapi.svg | ||
| type: Model Provider | ||
| version: Haystack 2.0 | ||
| toc: true | ||
| --- | ||
|
|
||
| ### Table of Contents | ||
|
|
||
| - [Overview](#overview) | ||
| - [Installation](#installation) | ||
| - [Usage](#usage) | ||
| - [License](#license) | ||
|
|
||
| ## Overview | ||
|
|
||
| [`AIMLAPIChatGenerator`](https://docs.haystack.deepset.ai/docs/aimlapichatgenerator) lets you call any of the models that AIMLAPI serves behind an OpenAI-compatible `/chat/completions` endpoint. AIMLAPI routes the request to the requested provider while maintaining the familiar OpenAI payload schema, so you can reuse existing Haystack pipelines or agents with minimal changes. | ||
|
|
||
| AIMLAPI extends the base OpenAI integration with: | ||
|
|
||
| - **Direct AIMLAPI routing** – requests are sent to `https://api.aimlapi.com/v1` and can target any model AIMLAPI exposes by passing the `model` name. | ||
| - **Tool calling support** – pass Haystack [`Tool`](https://docs.haystack.deepset.ai/reference/tool) objects to the generator to enable function calling workflows. | ||
| - **Streaming callbacks** – supply `streaming_callback` to receive tokens as they are generated. | ||
| - **Flexible extras** – forward provider-specific parameters by using `generation_kwargs` and `extra_body`. | ||
|
|
||
| To follow along with the example below, set the `AIMLAPI_API_KEY` environment variable to your API token. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install aimlapi-haystack | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| You can use `AIMLAPIChatGenerator` on its own or as part of a larger pipeline. The snippet below shows a minimal chat interaction that asks the model a question and prints the assistant reply. | ||
|
|
||
| ```python | ||
| import os | ||
| from haystack.dataclasses import ChatMessage | ||
| from haystack_integrations.components.generators.aimlapi import AIMLAPIChatGenerator | ||
|
|
||
| os.environ["AIMLAPI_API_KEY"] = "YOUR_AIMLAPI_KEY" | ||
|
|
||
| chat = AIMLAPIChatGenerator(model="openai/gpt-4o") | ||
| result = chat.run([ | ||
| ChatMessage.from_user("What's the capital of France?") | ||
| ]) | ||
|
|
||
| print(result["replies"][0].text) | ||
| ``` | ||
|
|
||
| If you want the model to call tools, pass the tool definitions to the generator. AIMLAPI will return tool call information that you can route to the relevant function and then send back to the model. The example in [`examples/aimlapi_with_tools_example.py`](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/aimlapi/examples/aimlapi_with_tools_example.py) demonstrates the full round-trip. | ||
|
|
||
| ## License | ||
|
|
||
| This integration is distributed under the [Apache 2.0 License](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/aimlapi/LICENSE.txt). | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.