Claude 4.5 Sonnet
Model Overview
A major improvement over Claude 4 Sonnet, offering better coding abilities, stronger reasoning, and more accurate responses to your instructions.
How to Make a Call
API Schema
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.
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.
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.
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.
An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
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.
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.
If set to True, the model response data will be streamed to the client as it is generated using server-sent events.
falseAn 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.
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.
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
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.
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.
Whether to enable parallel function calling during tool use.
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.
An object specifying the format that the model must output.
async function main() {
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'anthropic/claude-sonnet-4.5',
messages:[
{
role:'user',
content: 'Hello'
}
],
}),
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
}
main();{
"id": "text",
"object": "text",
"created": 1,
"choices": [
{
"index": 1,
"message": {
"role": "text",
"content": "text",
"refusal": null,
"annotations": [
{
"type": "text",
"url_citation": {
"end_index": 1,
"start_index": 1,
"title": "text",
"url": "text"
}
}
],
"audio": {
"id": "text",
"data": "text",
"transcript": "text",
"expires_at": 1
},
"tool_calls": [
{
"id": "text",
"type": "text",
"function": {
"arguments": "text",
"name": "text"
}
}
]
},
"finish_reason": "stop",
"logprobs": {
"content": [
{
"bytes": [
1
],
"logprob": 1,
"token": "text",
"top_logprobs": [
{
"bytes": [
1
],
"logprob": 1,
"token": "text"
}
]
}
],
"refusal": []
}
}
],
"model": "text",
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1,
"completion_tokens_details": {
"accepted_prediction_tokens": 1,
"audio_tokens": 1,
"reasoning_tokens": 1,
"rejected_prediction_tokens": 1
},
"prompt_tokens_details": {
"audio_tokens": 1,
"cached_tokens": 1
}
}
}Code Example
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-sonnet-4.5",
"messages":[
{
"role":"user",
"content":"Hello" # insert your prompt here, instead of Hello
}
],
"enable_thinking": False
}
)
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: 'anthropic/claude-sonnet-4.5',
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();Last updated
Was this helpful?