🧭Documentation Map
Learn how to get started with the AI/ML API
Browse Models
Going Deeper
Have a Minute? Help Make the Docs Better!

Last updated
Was this helpful?
Learn how to get started with the AI/ML API

Last updated
Was this helpful?
Was this helpful?
from openai import OpenAI
client = OpenAI(
base_url="https://api.aimlapi.com/v1",
api_key="<YOUR_AIMLAPI_KEY>",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a one-sentence story about numbers."}]
)
print(response.choices[0].message.content)