POST
/
v1
/
messages
curl -X POST https://www.anyfast.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get the current weather in a given location",
        "input_schema": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. San Francisco, CA"
            }
          },
          "required": ["location"]
        }
      }
    ],
    "messages": [
      {
        "role": "user",
        "content": "What is the weather like in San Francisco?"
      }
    ],
    "stream": true
  }'
{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "tool_use",
      "id": "toolu_01A09q90qw90lq917835lq9",
      "name": "get_weather",
      "input": {
        "location": "San Francisco, CA"
      }
    }
  ],
  "model": "claude-sonnet-4-20250514",
  "stop_reason": "tool_use",
  "usage": {
    "input_tokens": 384,
    "output_tokens": 62
  }
}
Official documentation: https://docs.anthropic.com/en/docs/build-with-claude/tool-use
Use Anthropic Claude models to perform function calling (tool use) in native format.

Request Parameters

model
string
required
The model to use. Available models include:
  • claude-haiku-4-5-20251001
  • claude-sonnet-4-20250514
  • claude-opus-4-5-20251101
max_tokens
integer
required
The maximum number of tokens to generate before stopping.
messages
array
required
Input messages. Each message has a role and content.
tools
array
required
An array of tools the model may use. Each tool includes:
  • name (string): The name of the tool
  • description (string): Description of what the tool does
  • input_schema (object): JSON Schema defining the tool’s input parameters
stream
boolean
default:"false"
Whether to incrementally stream the response using server-sent events.
temperature
number
default:"1"
Amount of randomness injected into the response. Ranges from 0.0 to 1.0.

Response

id
string
Unique identifier for the message.
type
string
Object type, which is message.
content
array
Content generated by the model. When tool use is triggered, includes tool_use blocks.
stop_reason
string
The reason the model stopped. Will be tool_use when the model wants to call a tool.
curl -X POST https://www.anyfast.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get the current weather in a given location",
        "input_schema": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. San Francisco, CA"
            }
          },
          "required": ["location"]
        }
      }
    ],
    "messages": [
      {
        "role": "user",
        "content": "What is the weather like in San Francisco?"
      }
    ],
    "stream": true
  }'
{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "tool_use",
      "id": "toolu_01A09q90qw90lq917835lq9",
      "name": "get_weather",
      "input": {
        "location": "San Francisco, CA"
      }
    }
  ],
  "model": "claude-sonnet-4-20250514",
  "stop_reason": "tool_use",
  "usage": {
    "input_tokens": 384,
    "output_tokens": 62
  }
}