Quickstart
This guide helps you get started with Azerion Intelligence by obtaining an API key, making a test request, and using the OpenAI SDK.
Get an API Key or Access Token
To use the authenticated endpoints of the Azerion Intelligence API, you need either an API key or an access token obtained via social login.
Refer to the Authentication guide for detailed instructions on obtaining your credentials.
Keep your API key and access tokens secure and do not share them publicly. Treat them like passwords.
Test Request
You can test your API key by making a request to an authenticated endpoint using a tool like curl
. This example uses the Chat Completions endpoint.
Prerequisites:
- Your Azerion Intelligence API key.
curl
installed on your system.
Steps:
-
Open your terminal or command prompt.
-
Run the following
curl
command. Replace<YOUR_API_KEY>
with your actual API key.curl https://api.azerion.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {{access_token}}" \
-d '{
"model": "meta.llama3-3-70b-instruct-v1:0", # Replace with an available model slug
"messages": [
{
"role": "user",
"content": "Hello, world!"
}
]
}'Replace PlaceholderReplace
{{access_token}}
with your actual API key or access token. -
If your API key is valid and the request is successful, you will receive a JSON response containing the model's reply.
This confirms that you can successfully authenticate and interact with the API.
Using the OpenAI SDK (Optional)
Because Azerion Intelligence is OpenAI-compatible, you can often use the official OpenAI SDKs by simply configuring the base URL and using your Azerion Intelligence API key. This example uses the Python SDK.
Prerequisites
- Your Azerion Intelligence API key or access token (preferably stored in an environment variable, e.g.,
AZERION_AI_API_KEY
). - Python installed (3.7+ recommended).
- The
openai
Python library installed (pip install openai
).
Steps
-
Set your API key as an environment variable:
# On Linux/macOS
export AZERION_AI_API_KEY='<YOUR_API_KEY>'
# On PowerShell (Windows)
# $env:AZERION_AI_API_KEY='<YOUR_API_KEY>' -
Create a Python file (e.g.,
quickstart_sdk.py
) and add the following code:import os
from openai import OpenAI
# Get API key or access token from environment variable
api_key_or_token = os.environ.get("AZERION_AI_API_KEY") # Or AZERION_ACCESS_TOKEN
if not api_key_or_token:
print("Error: AZERION_AI_API_KEY (or AZERION_ACCESS_TOKEN) environment variable not set.")
exit()
# 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"
)
print("Sending request via OpenAI SDK...")
try:
# Make a chat completion call using the compatible method
chat_completion = client.chat.completions.create(
model="azerion-ai-fast-001", # Use an available model name
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is 1 + 1?"},
],
)
# Print the model's response
if chat_completion.choices:
message_content = chat_completion.choices[0].message.content
print("\nAssistant:", message_content)
else:
print("No response received.")
except Exception as e:
print(f"\nAn error occurred: {e}")
print("Please check your API key/access token and environment variable.") -
Run the Python script:
python quickstart_sdk.py