Migrating from OpenAI
This guide provides instructions and considerations for developers migrating their applications from the OpenAI API to Azerion Intelligence. Due to Azerion Intelligence's OpenAI compatibility, the migration process is designed to be as smooth as possible.
Key Similarities
Azerion Intelligence's API is designed to be largely compatible with the OpenAI API, particularly for core functionalities like chat completions. This means:
- Similar Endpoint Structures: Many endpoints, especially
/v1/chat/completions
, follow a similar path and structure. - Compatible Request/Response Formats: The JSON request and response bodies for common tasks are designed to be compatible.
- Bearer Token Authentication: Both platforms use the
Authorization: Bearer
header for authentication.
Migration Steps
The primary steps for migrating from OpenAI to Azerion Intelligence involve updating your API base URL and using your Azerion Intelligence credentials.
-
Obtain Azerion Intelligence Credentials:
- If you were using OpenAI API keys, you will need to obtain an API key from your Azerion Intelligence account settings. Refer to the Authentication guide for details.
-
Update API Base URL:
- Change the base URL in your API requests from the OpenAI API URL (
https://api.openai.com/v1
) to the Azerion Intelligence API URL (https://api.azerion.ai/v1
).
- Change the base URL in your API requests from the OpenAI API URL (
-
Update Authentication Header:
- Replace your OpenAI API key with your Azerion Intelligence API key or access token in the
Authorization: Bearer
header.
Authorization: Bearer YOUR_AZERION_INTELLIGENCE_KEY_OR_TOKEN
- Replace your OpenAI API key with your Azerion Intelligence API key or access token in the
-
Review Model Names:
- While the API structure is similar, the names or slugs of the available models may differ.
- Use the List Models endpoint to get a list of available models and their slugs on the Azerion Intelligence platform.
- Update the
model
parameter in your requests to use the appropriate Azerion Intelligence model slug.
-
Test and Verify:
- Thoroughly test your application after making the changes to ensure that API calls are successful and responses are handled correctly.
- Pay close attention to the format of responses, especially for less common parameters or endpoints, as there might be minor differences.
Using OpenAI SDKs
As Azerion Intelligence is OpenAI-compatible, you can often continue using the official OpenAI SDKs by simply configuring the base_url
parameter to point to the Azerion Intelligence API.
Example (Python SDK):
import os
from openai import OpenAI
# Get your Azerion Intelligence API key or access token
api_key_or_token = os.environ.get("AZERION_AI_API_KEY") # Or AZERION_ACCESS_TOKEN
# Initialize the client, pointing to the Azerion Intelligence base URL
client = OpenAI(
api_key=api_key_or_token,
base_url="https://api.azerion.ai/v1"
)
# Now you can use the client methods similar to how you would with OpenAI
try:
chat_completion = client.chat.completions.create(
model="azerion-ai-fast-001", # Use an available model slug from Azerion Intelligence
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me a short story."},
],
)
print(chat_completion.choices[0].message.content)
except Exception as e:
print(f"An error occurred: {e}")
print("Please check your credentials and base URL.")
Considerations
- Available Models: The set of models available on Azerion Intelligence may differ from OpenAI. Review the available models to find the best fit for your needs.
- Pricing and Rate Limits: Pricing and rate limits will be specific to the Azerion Intelligence platform. Refer to the relevant documentation sections for details.
- Endpoint Coverage: While core endpoints are compatible, not all OpenAI endpoints may be available on Azerion Intelligence, and vice versa. Consult the API Reference for the full list of supported endpoints.
- Specific Features: Some advanced features or parameters might be implemented differently or not be available.
If you encounter any issues during the migration process, please refer to the FAQ or contact support.