Managed Inference and Agents API with Claude 3.7 Sonnet
Last updated May 13, 2025
Table of Contents
Claude 3.7 Sonnet is a text-to-text large language model (LLM) in Anthropic’s Claude 3.7 family that supports conversational chat, tool calling, and enhanced long-context reasoning with its extended thinking feature. It offers advanced intelligence, speed, and cost-efficiency, and outperforms previous models like Claude 3.5 Sonnet and Claude 3 Opus.
- Model ID:
claude-3-7-sonnet
- Regions:
us
,eu
When to Use This Model
Claude 3.7 Sonnet is ideal for sophisticated code generation, complex chat interactions, and orchestrating multi-step workflows. This model is more expensive than alternatives like Claude 3.5 Haiku, but it’s also more intelligent and detail-oriented.
Usage
Claude 3.7 Sonnet follows our Claude v1/chat/completions API schema.
To provision access to the model, attach claude-3-7-sonnet
to your app $APP_NAME
:
heroku ai:models:create -a $APP_NAME claude-3-7-sonnet
Using config variables, you can invoke claude-3-7-sonnet
in a variety of ways:
- Heroku CLI
ai
plugin (heroku ai:models:call
) curl
- Python
- Ruby
- Javascript
Example curl Request
Get started quickly with an example request:
export INFERENCE_MODEL_ID=$(heroku config:get -a $APP_NAME INFERENCE_MODEL_ID)
export INFERENCE_KEY=$(heroku config:get -a $APP_NAME INFERENCE_KEY)
export INFERENCE_URL=$(heroku config:get -a $APP_NAME INFERENCE_URL)
curl $INFERENCE_URL/v1/chat/completions \
-H "Authorization: Bearer $INFERENCE_KEY" \
-d @- <<EOF
{
"model": "$INFERENCE_MODEL_ID",
"messages": [
{ "role": "user", "content": "Hello!" },
{ "role": "assistant", "content": "Hi there! How can I assist you today?" },
{ "role": "user", "content": "What's the weather like in Portland, Oregon right now?" }
],
"max_tokens": 2048,
"stream": false,
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Fetches the current weather for a given city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The name of the city to get weather for."
}
},
"required": ["city"]
}
}
}
],
"extended_thinking": {
"enabled": true,
"budget_tokens": 1024,
"include_reasoning": true
},
"tool_choice": "auto"
}
EOF