API Reference
Completions
Send a list of messages and receive a model-generated completion. Supports streaming, web search, research mode, and external toolkits.
POST
/
api
/
v1
/
completions
Completions
curl --request POST \
--url https://www.chat.ironlabs.ai/api/v1/completions \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
]
}
],
"models": {},
"fallback_models": {},
"stream": true,
"temperature": 123,
"maxTokens": 123,
"maxRetries": 123,
"search": true,
"conversationId": {}
}
'import requests
url = "https://www.chat.ironlabs.ai/api/v1/completions"
payload = {
"messages": [
{
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
]
}
],
"models": {},
"fallback_models": {},
"stream": True,
"temperature": 123,
"maxTokens": 123,
"maxRetries": 123,
"search": True,
"conversationId": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{role: '<string>', content: [{type: '<string>', text: '<string>'}]}],
models: {},
fallback_models: {},
stream: true,
temperature: 123,
maxTokens: 123,
maxRetries: 123,
search: true,
conversationId: {}
})
};
fetch('https://www.chat.ironlabs.ai/api/v1/completions', 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://www.chat.ironlabs.ai/api/v1/completions",
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([
'messages' => [
[
'role' => '<string>',
'content' => [
[
'type' => '<string>',
'text' => '<string>'
]
]
]
],
'models' => [
],
'fallback_models' => [
],
'stream' => true,
'temperature' => 123,
'maxTokens' => 123,
'maxRetries' => 123,
'search' => true,
'conversationId' => [
]
]),
CURLOPT_HTTPHEADER => [
"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://www.chat.ironlabs.ai/api/v1/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n }\n ],\n \"models\": {},\n \"fallback_models\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"maxTokens\": 123,\n \"maxRetries\": 123,\n \"search\": true,\n \"conversationId\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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://www.chat.ironlabs.ai/api/v1/completions")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n }\n ],\n \"models\": {},\n \"fallback_models\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"maxTokens\": 123,\n \"maxRetries\": 123,\n \"search\": true,\n \"conversationId\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chat.ironlabs.ai/api/v1/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n }\n ],\n \"models\": {},\n \"fallback_models\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"maxTokens\": 123,\n \"maxRetries\": 123,\n \"search\": true,\n \"conversationId\": {}\n}"
response = http.request(request)
puts response.read_body{
"provider": "openai",
"model": "gpt-4o",
"responseMessageId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"conversationId": "conv_xyz789abc",
"conversationTitle": "Explain LLM routing",
"message": {
"role": "assistant",
"type": "text",
"content": [
{
"type": "text",
"text": "LLM routing is the process of automatically selecting the best language model for a given request based on factors like cost, speed, and capability."
}
]
},
"usage": {
"promptTokens": 120,
"completionTokens": 80,
"totalTokens": 200,
"reasoningTokens": 0,
"costs": {
"input_tokens_cost": 0.0000600,
"output_tokens_cost": 0.0003200,
"total_tokens_cost": 0.0003800
}
},
"latency": 1240,
"ttft": 320
}
{
"provider": "openai",
"model": "gpt-4o",
"responseMessageId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "text",
"text": "LLM routing",
"message": {
"role": "assistant",
"type": "text",
"content": [
{
"type": "text",
"text": "LLM routing"
}
]
}
}
{
"error": "Unauthorized",
"message": "Invalid or missing API key."
}
{
"error": "Validation Error",
"message": "models: At least one model must be provided."
}
Body
array
required
Array of message objects representing the conversation history.
array of strings
required
One or more models to use for the completion, in
provider/model format. At least one must be provided.["openai/gpt-4o", "anthropic/claude-3-5-sonnet-20241022"]
array of strings
Optional list of fallback models to try if the primary models fail, in
provider/model format.["google/gemini-2.0-flash"]
boolean
default:"false"
When
true, the response is streamed as server-sent events (SSE).number
Sampling temperature between
0 and 1. Higher values produce more random output. Defaults to the model’s preset.integer
Maximum number of tokens to generate in the response.
integer
Number of times to retry a failed model request before falling back or erroring.
boolean
Enable real-time web search to ground the response in current information.
string (UUID)
Associates this request with an existing conversation for context tracking.
Examples
curl -X POST https://www.chat.ironlabs.ai/api/v1/completions \
-H "Authorization: Bearer <IAI_API_Key>" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]},
{"role": "user", "content": [{"type": "text", "text": "Explain how LLM routing works."}]}
],
"models": ["openai/gpt-4o", "anthropic/claude-3-5-sonnet-20241022"],
"stream": false,
"temperature": 0.7,
"maxTokens": 1024
}'
curl -X POST https://www.chat.ironlabs.ai/api/v1/completions \
-H "Authorization: Bearer <IAI_API_Key>" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": [{"type": "text", "text": "Write a Python quicksort."}]}
],
"models": ["openai/gpt-4o"],
"stream": true
}'
import requests
response = requests.post(
"https://www.chat.ironlabs.ai/api/v1/completions",
headers={
"Authorization": "Bearer <IAI_API_Key>",
"Content-Type": "application/json"
},
json={
"messages": [
{"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]},
{"role": "user", "content": [{"type": "text", "text": "Explain how LLM routing works."}]}
],
"models": ["openai/gpt-4o", "anthropic/claude-3-5-sonnet-20241022"],
"stream": False,
"temperature": 0.7,
"maxTokens": 1024
}
)
print(response.json())
const response = await fetch("https://www.chat.ironlabs.ai/api/v1/completions", {
method: "POST",
headers: {
"Authorization": "Bearer <IAI_API_Key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
messages: [
{ role: "system", content: [{ type: "text", text: "You are a helpful assistant." }] },
{ role: "user", content: [{ type: "text", text: "Explain how LLM routing works." }] }
],
models: ["openai/gpt-4o", "anthropic/claude-3-5-sonnet-20241022"],
stream: false,
temperature: 0.7,
maxTokens: 1024
})
});
const data = await response.json();
console.log(data);
Response
string
The provider that handled the request. E.g.
"openai", "anthropic".string
The model that generated the response. E.g.
"gpt-4o".string (UUID)
Unique identifier for the generated assistant message.
string
Type of the response chunk. Currently
"text". Present on streaming chunks.string
The generated text fragment. Present on streaming chunks.
object
string
ID of the conversation this completion belongs to.
string
Auto-generated title for the conversation derived from the first message.
object
Token usage and cost breakdown for the request.
Show Usage object
Show Usage object
integer
Number of tokens in the input messages.
integer
Number of tokens in the generated response.
integer
Total tokens used (
promptTokens + completionTokens).integer
Tokens used for internal reasoning (e.g. thinking models).
0 for standard models.integer
Total request latency in milliseconds from request received to response complete.
integer
Time to first token in milliseconds.
{
"provider": "openai",
"model": "gpt-4o",
"responseMessageId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"conversationId": "conv_xyz789abc",
"conversationTitle": "Explain LLM routing",
"message": {
"role": "assistant",
"type": "text",
"content": [
{
"type": "text",
"text": "LLM routing is the process of automatically selecting the best language model for a given request based on factors like cost, speed, and capability."
}
]
},
"usage": {
"promptTokens": 120,
"completionTokens": 80,
"totalTokens": 200,
"reasoningTokens": 0,
"costs": {
"input_tokens_cost": 0.0000600,
"output_tokens_cost": 0.0003200,
"total_tokens_cost": 0.0003800
}
},
"latency": 1240,
"ttft": 320
}
{
"provider": "openai",
"model": "gpt-4o",
"responseMessageId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "text",
"text": "LLM routing",
"message": {
"role": "assistant",
"type": "text",
"content": [
{
"type": "text",
"text": "LLM routing"
}
]
}
}
{
"error": "Unauthorized",
"message": "Invalid or missing API key."
}
{
"error": "Validation Error",
"message": "models: At least one model must be provided."
}
Was this page helpful?
⌘I
Completions
curl --request POST \
--url https://www.chat.ironlabs.ai/api/v1/completions \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
]
}
],
"models": {},
"fallback_models": {},
"stream": true,
"temperature": 123,
"maxTokens": 123,
"maxRetries": 123,
"search": true,
"conversationId": {}
}
'import requests
url = "https://www.chat.ironlabs.ai/api/v1/completions"
payload = {
"messages": [
{
"role": "<string>",
"content": [
{
"type": "<string>",
"text": "<string>"
}
]
}
],
"models": {},
"fallback_models": {},
"stream": True,
"temperature": 123,
"maxTokens": 123,
"maxRetries": 123,
"search": True,
"conversationId": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{role: '<string>', content: [{type: '<string>', text: '<string>'}]}],
models: {},
fallback_models: {},
stream: true,
temperature: 123,
maxTokens: 123,
maxRetries: 123,
search: true,
conversationId: {}
})
};
fetch('https://www.chat.ironlabs.ai/api/v1/completions', 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://www.chat.ironlabs.ai/api/v1/completions",
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([
'messages' => [
[
'role' => '<string>',
'content' => [
[
'type' => '<string>',
'text' => '<string>'
]
]
]
],
'models' => [
],
'fallback_models' => [
],
'stream' => true,
'temperature' => 123,
'maxTokens' => 123,
'maxRetries' => 123,
'search' => true,
'conversationId' => [
]
]),
CURLOPT_HTTPHEADER => [
"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://www.chat.ironlabs.ai/api/v1/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n }\n ],\n \"models\": {},\n \"fallback_models\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"maxTokens\": 123,\n \"maxRetries\": 123,\n \"search\": true,\n \"conversationId\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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://www.chat.ironlabs.ai/api/v1/completions")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n }\n ],\n \"models\": {},\n \"fallback_models\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"maxTokens\": 123,\n \"maxRetries\": 123,\n \"search\": true,\n \"conversationId\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chat.ironlabs.ai/api/v1/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": [\n {\n \"type\": \"<string>\",\n \"text\": \"<string>\"\n }\n ]\n }\n ],\n \"models\": {},\n \"fallback_models\": {},\n \"stream\": true,\n \"temperature\": 123,\n \"maxTokens\": 123,\n \"maxRetries\": 123,\n \"search\": true,\n \"conversationId\": {}\n}"
response = http.request(request)
puts response.read_body{
"provider": "openai",
"model": "gpt-4o",
"responseMessageId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"conversationId": "conv_xyz789abc",
"conversationTitle": "Explain LLM routing",
"message": {
"role": "assistant",
"type": "text",
"content": [
{
"type": "text",
"text": "LLM routing is the process of automatically selecting the best language model for a given request based on factors like cost, speed, and capability."
}
]
},
"usage": {
"promptTokens": 120,
"completionTokens": 80,
"totalTokens": 200,
"reasoningTokens": 0,
"costs": {
"input_tokens_cost": 0.0000600,
"output_tokens_cost": 0.0003200,
"total_tokens_cost": 0.0003800
}
},
"latency": 1240,
"ttft": 320
}
{
"provider": "openai",
"model": "gpt-4o",
"responseMessageId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "text",
"text": "LLM routing",
"message": {
"role": "assistant",
"type": "text",
"content": [
{
"type": "text",
"text": "LLM routing"
}
]
}
}
{
"error": "Unauthorized",
"message": "Invalid or missing API key."
}
{
"error": "Validation Error",
"message": "models: At least one model must be provided."
}