curl --request POST \
--url https://api.edenai.run/v3/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"cache_control": {
"type": "ephemeral",
"ttl": "<string>"
}
}
],
"routing": {
"sticky": true,
"allow_fallbacks": true,
"quality_cost": 5,
"allowed_providers": [
"<string>"
]
},
"fallbacks": [
"<string>"
],
"session_id": "<string>",
"router_candidates": [
"<string>"
],
"max_tokens": 1024,
"system": "<string>",
"temperature": 1,
"top_p": 0.5,
"top_k": 123,
"stream": false,
"stop_sequences": [
"<string>"
],
"tools": [
{}
],
"tool_choice": {},
"metadata": {},
"thinking": {},
"extra_headers": {}
}
'import requests
url = "https://api.edenai.run/v3/v1/messages"
payload = {
"model": "<string>",
"messages": [
{
"content": "<string>",
"cache_control": {
"type": "ephemeral",
"ttl": "<string>"
}
}
],
"routing": {
"sticky": True,
"allow_fallbacks": True,
"quality_cost": 5,
"allowed_providers": ["<string>"]
},
"fallbacks": ["<string>"],
"session_id": "<string>",
"router_candidates": ["<string>"],
"max_tokens": 1024,
"system": "<string>",
"temperature": 1,
"top_p": 0.5,
"top_k": 123,
"stream": False,
"stop_sequences": ["<string>"],
"tools": [{}],
"tool_choice": {},
"metadata": {},
"thinking": {},
"extra_headers": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{content: '<string>', cache_control: {type: 'ephemeral', ttl: '<string>'}}],
routing: {
sticky: true,
allow_fallbacks: true,
quality_cost: 5,
allowed_providers: ['<string>']
},
fallbacks: ['<string>'],
session_id: '<string>',
router_candidates: ['<string>'],
max_tokens: 1024,
system: '<string>',
temperature: 1,
top_p: 0.5,
top_k: 123,
stream: false,
stop_sequences: ['<string>'],
tools: [{}],
tool_choice: {},
metadata: {},
thinking: {},
extra_headers: {}
})
};
fetch('https://api.edenai.run/v3/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.edenai.run/v3/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'content' => '<string>',
'cache_control' => [
'type' => 'ephemeral',
'ttl' => '<string>'
]
]
],
'routing' => [
'sticky' => true,
'allow_fallbacks' => true,
'quality_cost' => 5,
'allowed_providers' => [
'<string>'
]
],
'fallbacks' => [
'<string>'
],
'session_id' => '<string>',
'router_candidates' => [
'<string>'
],
'max_tokens' => 1024,
'system' => '<string>',
'temperature' => 1,
'top_p' => 0.5,
'top_k' => 123,
'stream' => false,
'stop_sequences' => [
'<string>'
],
'tools' => [
[
]
],
'tool_choice' => [
],
'metadata' => [
],
'thinking' => [
],
'extra_headers' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.edenai.run/v3/v1/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\",\n \"ttl\": \"<string>\"\n }\n }\n ],\n \"routing\": {\n \"sticky\": true,\n \"allow_fallbacks\": true,\n \"quality_cost\": 5,\n \"allowed_providers\": [\n \"<string>\"\n ]\n },\n \"fallbacks\": [\n \"<string>\"\n ],\n \"session_id\": \"<string>\",\n \"router_candidates\": [\n \"<string>\"\n ],\n \"max_tokens\": 1024,\n \"system\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"top_k\": 123,\n \"stream\": false,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {},\n \"extra_headers\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.edenai.run/v3/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\",\n \"ttl\": \"<string>\"\n }\n }\n ],\n \"routing\": {\n \"sticky\": true,\n \"allow_fallbacks\": true,\n \"quality_cost\": 5,\n \"allowed_providers\": [\n \"<string>\"\n ]\n },\n \"fallbacks\": [\n \"<string>\"\n ],\n \"session_id\": \"<string>\",\n \"router_candidates\": [\n \"<string>\"\n ],\n \"max_tokens\": 1024,\n \"system\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"top_k\": 123,\n \"stream\": false,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {},\n \"extra_headers\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.edenai.run/v3/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\",\n \"ttl\": \"<string>\"\n }\n }\n ],\n \"routing\": {\n \"sticky\": true,\n \"allow_fallbacks\": true,\n \"quality_cost\": 5,\n \"allowed_providers\": [\n \"<string>\"\n ]\n },\n \"fallbacks\": [\n \"<string>\"\n ],\n \"session_id\": \"<string>\",\n \"router_candidates\": [\n \"<string>\"\n ],\n \"max_tokens\": 1024,\n \"system\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"top_k\": 123,\n \"stream\": false,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {},\n \"extra_headers\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"model": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>",
"id": "<string>",
"name": "<string>",
"input": {},
"tool_use_id": "<string>",
"content": "<string>",
"is_error": true,
"source": {},
"thinking": "<string>",
"signature": "<string>"
}
],
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123
},
"type": "message",
"role": "assistant",
"stop_reason": "end_turn",
"stop_sequence": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Create Anthropic Message
Anthropic Messages API — native pass-through via litellm.
curl --request POST \
--url https://api.edenai.run/v3/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"content": "<string>",
"cache_control": {
"type": "ephemeral",
"ttl": "<string>"
}
}
],
"routing": {
"sticky": true,
"allow_fallbacks": true,
"quality_cost": 5,
"allowed_providers": [
"<string>"
]
},
"fallbacks": [
"<string>"
],
"session_id": "<string>",
"router_candidates": [
"<string>"
],
"max_tokens": 1024,
"system": "<string>",
"temperature": 1,
"top_p": 0.5,
"top_k": 123,
"stream": false,
"stop_sequences": [
"<string>"
],
"tools": [
{}
],
"tool_choice": {},
"metadata": {},
"thinking": {},
"extra_headers": {}
}
'import requests
url = "https://api.edenai.run/v3/v1/messages"
payload = {
"model": "<string>",
"messages": [
{
"content": "<string>",
"cache_control": {
"type": "ephemeral",
"ttl": "<string>"
}
}
],
"routing": {
"sticky": True,
"allow_fallbacks": True,
"quality_cost": 5,
"allowed_providers": ["<string>"]
},
"fallbacks": ["<string>"],
"session_id": "<string>",
"router_candidates": ["<string>"],
"max_tokens": 1024,
"system": "<string>",
"temperature": 1,
"top_p": 0.5,
"top_k": 123,
"stream": False,
"stop_sequences": ["<string>"],
"tools": [{}],
"tool_choice": {},
"metadata": {},
"thinking": {},
"extra_headers": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{content: '<string>', cache_control: {type: 'ephemeral', ttl: '<string>'}}],
routing: {
sticky: true,
allow_fallbacks: true,
quality_cost: 5,
allowed_providers: ['<string>']
},
fallbacks: ['<string>'],
session_id: '<string>',
router_candidates: ['<string>'],
max_tokens: 1024,
system: '<string>',
temperature: 1,
top_p: 0.5,
top_k: 123,
stream: false,
stop_sequences: ['<string>'],
tools: [{}],
tool_choice: {},
metadata: {},
thinking: {},
extra_headers: {}
})
};
fetch('https://api.edenai.run/v3/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.edenai.run/v3/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'content' => '<string>',
'cache_control' => [
'type' => 'ephemeral',
'ttl' => '<string>'
]
]
],
'routing' => [
'sticky' => true,
'allow_fallbacks' => true,
'quality_cost' => 5,
'allowed_providers' => [
'<string>'
]
],
'fallbacks' => [
'<string>'
],
'session_id' => '<string>',
'router_candidates' => [
'<string>'
],
'max_tokens' => 1024,
'system' => '<string>',
'temperature' => 1,
'top_p' => 0.5,
'top_k' => 123,
'stream' => false,
'stop_sequences' => [
'<string>'
],
'tools' => [
[
]
],
'tool_choice' => [
],
'metadata' => [
],
'thinking' => [
],
'extra_headers' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.edenai.run/v3/v1/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\",\n \"ttl\": \"<string>\"\n }\n }\n ],\n \"routing\": {\n \"sticky\": true,\n \"allow_fallbacks\": true,\n \"quality_cost\": 5,\n \"allowed_providers\": [\n \"<string>\"\n ]\n },\n \"fallbacks\": [\n \"<string>\"\n ],\n \"session_id\": \"<string>\",\n \"router_candidates\": [\n \"<string>\"\n ],\n \"max_tokens\": 1024,\n \"system\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"top_k\": 123,\n \"stream\": false,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {},\n \"extra_headers\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.edenai.run/v3/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\",\n \"ttl\": \"<string>\"\n }\n }\n ],\n \"routing\": {\n \"sticky\": true,\n \"allow_fallbacks\": true,\n \"quality_cost\": 5,\n \"allowed_providers\": [\n \"<string>\"\n ]\n },\n \"fallbacks\": [\n \"<string>\"\n ],\n \"session_id\": \"<string>\",\n \"router_candidates\": [\n \"<string>\"\n ],\n \"max_tokens\": 1024,\n \"system\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"top_k\": 123,\n \"stream\": false,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {},\n \"extra_headers\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.edenai.run/v3/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"cache_control\": {\n \"type\": \"ephemeral\",\n \"ttl\": \"<string>\"\n }\n }\n ],\n \"routing\": {\n \"sticky\": true,\n \"allow_fallbacks\": true,\n \"quality_cost\": 5,\n \"allowed_providers\": [\n \"<string>\"\n ]\n },\n \"fallbacks\": [\n \"<string>\"\n ],\n \"session_id\": \"<string>\",\n \"router_candidates\": [\n \"<string>\"\n ],\n \"max_tokens\": 1024,\n \"system\": \"<string>\",\n \"temperature\": 1,\n \"top_p\": 0.5,\n \"top_k\": 123,\n \"stream\": false,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {},\n \"extra_headers\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"model": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>",
"id": "<string>",
"name": "<string>",
"input": {},
"tool_use_id": "<string>",
"content": "<string>",
"is_error": true,
"source": {},
"thinking": "<string>",
"signature": "<string>"
}
],
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123
},
"type": "message",
"role": "assistant",
"stop_reason": "end_turn",
"stop_sequence": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Show child attributes
Show child attributes
How to pick between the providers that serve the requested model. Applies when model is a model name with no provider prefix (e.g. 'gpt-5.5'); ignored for a concrete 'provider/model' id, which already names its provider. With model='@edenai' the platform chooses the model too: quality_cost steers that choice, and the provider fields apply whenever the chosen model is a provider-less name.
Show child attributes
Show child attributes
List of fallback model IDs to try if the primary model fails. Models are tried in order. Example: ['anthropic/claude-3-opus', 'openai/gpt-4o']
3Identifies a conversation, so its requests keep reaching the provider that holds its prompt cache. Any stable string you choose — a thread id, a ticket number, an agent run. Also accepted as the x-session-id header, for clients that cannot add body fields; the body field wins if both are sent. Without one, a conversation is recognised from its opening messages instead.
256Models the '@edenai' router may choose BETWEEN — it picks the model, whereas routing picks the provider for a model you already named. Used only when model='@edenai'. Each entry is a bare model name (e.g. 'gpt-5.5' — the winner's provider is then picked like any provider-less request) or a 'provider/model' id (e.g. 'openai/gpt-5-nano' — the winner is served by that exact provider). Entries the router cannot rank are skipped and listed under edenai_metadata.routing.auto.dropped; entries naming a model already in the list collapse into its earliest spelling, which decides how the winner is returned. The request fails only when no entry is left. If not provided, the router chooses from a default pool of eligible catalog models. At most 64 entries of up to 128 characters each.
64128x >= 00 <= x <= 20 <= x <= 1Show child attributes
Show child attributes
Response
Successful Response
Response body for POST /v1/messages (non-streaming).
Unique identifier for the message.
Model that generated the message.
Ordered list of content blocks produced by the model.
Show child attributes
Show child attributes
Token usage for the request.
Show child attributes
Show child attributes
Object type. Always 'message' for this endpoint.
"message"Conversational role of the response.
"assistant"Reason generation stopped, if known.
end_turn, max_tokens, stop_sequence, tool_use Custom stop sequence that triggered the stop, if any.