Supported SDKs [OLD]
REST API
Authorization
headers: {
Authorization: "Bearer <YOUR_AIMLAPI_KEY>",
}, headers={
"Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
}, --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \Request Example
fetch("https://api.aimlapi.com/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-4o",
messages: [
{
role: "user",
content: "What kind of model are you?",
},
],
max_tokens: 512,
}),
})
.then((res) => res.json())
.then(console.log);import requests
import json
response = requests.post(
url="https://api.aimlapi.com/chat/completions",
headers={
"Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type": "application/json",
},
data=json.dumps(
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "What kind of model are you?",
},
],
"max_tokens": 512,
"stream": False,
}
),
)
response.raise_for_status()
print(response.json())OpenAI
Example Code
AI/ML API Python library
Installation
Request Example
Next Steps
Last updated
Was this helpful?