Claude 3.7 Sonnet

This documentation is valid for the following list of our models:

  • claude-3-7-sonnet-20250219

  • claude-3-7-sonnet-latest

  • anthropic/claude-3.7-sonnet

Model Overview

Anthropic's latest hybrid reasoning model, designed to tackle complex tasks requiring both rapid inference and detailed problem-solving. It introduces a dual-mode operation, combining standard language generation with extended thinking capabilities.

How to Make a Call

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.

API Schema

Generate a conversational response using a language model.

post

Creates a chat completion using a language model, allowing interactive conversation by predicting the next response based on the given chat history. This is useful for AI-driven dialogue systems and virtual assistants.

Authorizations
Body
modelundefined · enumRequiredAvailable options:
messagesobject[]Required
stop_sequencesstring[]Optional
max_tokensnumber · min: 1OptionalDefault: 512
streambooleanOptionalDefault: false
frequency_penaltynumberOptional
top_pnumberOptional
top_knumberOptional
metadataobjectOptional
temperaturenumber · max: 1Optional
toolsobject[]Optional
tool_choiceany ofOptional
systemstringOptional
thinkingobjectOptional
Responses
post
POST /v1/chat/completions HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 466

{
  "model": "claude-3-7-sonnet-20250219",
  "messages": [
    {
      "content": "text",
      "role": "user"
    }
  ],
  "stop_sequences": [
    "text"
  ],
  "max_tokens": 1,
  "stream": true,
  "frequency_penalty": 1,
  "top_p": 1,
  "top_k": 1,
  "metadata": {
    "ANY_ADDITIONAL_PROPERTY": "text"
  },
  "temperature": 1,
  "tools": [
    {
      "name": "text",
      "description": "text",
      "input_schema": {
        "type": "object",
        "properties": null,
        "ANY_ADDITIONAL_PROPERTY": null
      }
    }
  ],
  "tool_choice": {
    "type": "auto"
  },
  "system": "text",
  "thinking": {
    "budget_tokens": 1,
    "type": "enabled"
  }
}
201Success

No content

Code Example (Python)

import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Content-Type":"application/json", 

        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type":"application/json"
    },
    json={
        "model":"anthropic/claude-3.7-sonnet",
        "messages":[
            {
                "role":"user",

                # Insert your question for the model here, instead of Hello:
                "content":"Hello"
            }
        ]
    }
)

data = response.json()
print(data)
Response
{'id': 'msg_01MmQNxa1E5mU8EyMXzT9zEU', 'object': 'chat.completion', 'model': 'claude-3-7-sonnet-20250219', 'choices': [{'index': 0, 'message': {'reasoning_content': '', 'content': "Hello! How can I assist you today? Whether you have a question, need information, or would like to discuss a particular topic, I'm here to help. What's on your mind?", 'role': 'assistant'}, 'finish_reason': 'end_turn', 'logprobs': None}], 'created': 1744218600, 'usage': {'prompt_tokens': 50, 'completion_tokens': 1323, 'total_tokens': 1373}}

Last updated

Was this helpful?