As of February 13, 2026, the streaming response format for Anthropic models has changed.
Model Overview
A cutting-edge model designed for rapid data processing and advanced reasoning capabilities. Excels in coding assistance, customer service interactions, and content moderation.
How to Make a Call
Step-by-Step Instructions
1️Setup You Can’t Skip
▪️Create an Account: Visit the AI/ML API website and create an account (if you don’t have one yet).
▪️Generate an API Key: After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.
2️Copy the code example
At the bottom of this page, you'll find a code example that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.
3️Modify the code example
▪️ Replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key from your account.
▪️ Insert your question or request into the content field—this is what the model will respond to.
4️(Optional) Adjust other optional parameters if needed
Only model and messages are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding API schema, which lists all available parameters along with notes on how to use them.
5️Run your modified code
Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our Quickstart guide.
API Schema
post
Body
modelstring · enumRequiredPossible values:
max_tokensnumber · min: 1Optional
The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
max_completion_tokensinteger · min: 1Optional
An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
streambooleanOptional
If set to True, the model response data will be streamed to the client as it is generated using server-sent events.
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
logprobsboolean · nullableOptional
Whether to return log probabilities of the output tokens or not. If True, returns the log probabilities of each output token returned in the content of message.
top_logprobsnumber · max: 20 · nullableOptional
An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to True if this parameter is used.
ninteger · min: 1 · nullableOptional
How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
seedinteger · min: 1Optional
This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
top_pnumber · min: 0.1 · max: 1Optional
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
temperaturenumber · max: 2Optional
What sampling temperature to use. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.
stopany ofOptional
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
stringOptional
or
string[]Optional
or
any · nullableOptional
tool_choiceany ofOptional
Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.
none is the default when no tools are present. auto is the default if tools are present.
string · enumOptional
none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.
Possible values:
or
parallel_tool_callsbooleanOptional
Whether to enable parallel function calling during tool use.
reasoning_effortstring · enumOptional
Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
Possible values:
response_formatone ofOptional
An object specifying the format that the model must output.
or
or
Responses
200Success
post
/v1/chat/completions
200Success
Code Example #1
Response
Code Example #2: Streaming Mode
As of February 13, 2026, the streaming response format for Anthropic models has changed.
Specifically, the usage fields were renamed as follows:
{
"id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
"object": "chat.completion",
"created": 1762343744,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
"refusal": null,
"annotations": null,
"audio": null,
"tool_calls": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"model": "anthropic/claude-3-5-haiku",
"usage": {
"prompt_tokens": 137,
"completion_tokens": 914,
"total_tokens": 1051,
"completion_tokens_details": null,
"prompt_tokens_details": null
}
}
import requests
import json # for getting a structured output with indentation
response = requests.post(
"https://api.aimlapi.com/v1/chat/completions",
headers={
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type":"application/json"
},
json={
"model":"claude-3-5-haiku",
"messages":[
{
"role":"user",
"content":"Hello" # insert your prompt here, instead of Hello
}
]
}
)
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
async function main() {
try {
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
method: 'POST',
headers: {
// Insert your AIML API Key instead of YOUR_AIMLAPI_KEY
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'claude-3-5-haiku',
messages:[
{
role:'user',
// Insert your question for the model here, instead of Hello:
content: 'Hello'
}
]
}),
});
if (!response.ok) {
throw new Error(`HTTP error! Status ${response.status}`);
}
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
} catch (error) {
console.error('Error', error);
}
}
main();
{'id': 'msg_01QfRmDBXVWcARjbwZBbJxrR', 'object': 'chat.completion', 'model': 'claude-3-5-haiku-20241022', 'choices': [{'index': 0, 'message': {'reasoning_content': '', 'content': 'Hi there! How are you doing today? Is there anything I can help you with?', 'role': 'assistant'}, 'finish_reason': 'end_turn', 'logprobs': None}], 'created': 1744218440, 'usage': {'prompt_tokens': 17, 'completion_tokens': 221, 'total_tokens': 238}}
import requests
import json # for getting a structured output with indentation
response = requests.post(
"https://api.aimlapi.com/v1/chat/completions",
headers={
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type":"application/json"
},
json={
"model":"anthropic/claude-3-5-haiku",
"messages":[
{
"role":"user",
"content":"Hi! What do you think about mankind?" # insert your prompt
}
]
}
)
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
curl -L \
--request POST \
--url 'https://api.aimlapi.com/v1/chat/completions' \
--header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "anthropic/claude-3-5-haiku",
"messages": [
{
"role": "user",
"content": "Hi! What do you think about mankind?"
}
],
"stream": true
}'
data: {"id":"msg_01MuATe8QKEhnksWHddPGVMD","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":"I want","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" to be","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" direct","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" and balance","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":"d in my response","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":". I recognize","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" humanity","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" has","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" tremendous","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" potential for","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" creativity","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":", compass","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":"ion, scientific","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" achievement","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":", and positive change.","role":"assistant","refusal":null}}],"created":1770995942,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" At","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" the same time, humans","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" are","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" complex","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" and capable","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" of both","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" remarkable","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" good and significant","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" destruct","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":"ive behaviors","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":". I try to view","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" humanity objectively,","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" acknowledging our","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" strengths an","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":"d ongoing","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" challenges. What are your","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" thoughts about","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":" humanity?","role":"assistant","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}
data: {"id":"","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null},"finish_reason":"stop"}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":{"prompt_tokens":16,"completion_tokens":77,"total_tokens":93}}
data: {"id":"","choices":[{"index":0,"finish_reason":"stop"}],"created":1770995943,"model":"claude-3-5-haiku-20241022","object":"chat.completion.chunk","usage":null}