Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.gmicloud.ai/llms.txt

Use this file to discover all available pages before exploring further.

Model ID
anthropic/claude-sonnet-4.5
Built with advanced reasoning and instruction-following capabilities, Claude Sonnet 4.5 excels at nuanced writing, multi-step problem solving, and tool use. It offers an optimal balance of intelligence and speed for demanding enterprise workloads.

API Usage

You can interact with the Anthropic Claude Sonnet 4.5 model through various programming languages and methods. Below are examples showing how to use the model’s API.

API Examples

Generate a model response using the chat endpoint of Anthropic Claude Sonnet 4.5.

Create chat completion

The Chat Completions API endpoint will generate a model response from a list of messages comprising a conversation.

Default

curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }'

Streaming

curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'

Image Input

curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
            }
          }
        ]
      }
    ],
    "max_completion_tokens": 300
  }'

Functions

curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [
      {
        "role": "user",
        "content": "What is the weather like in Boston today?"
      }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_current_weather",
          "description": "Get the current weather in a given location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA"
              },
              "unit": {
                "type": "string",
                "enum": ["celsius", "fahrenheit"]
              }
            },
            "required": ["location"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'

Python

import requests
import json

url = "https://api.gmi-serving.com/v1/chat/completions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer *************"
}

payload = {
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [
        {"role": "system", "content": "You are a helpful AI assistant"},
        {"role": "user", "content": "List 3 countries and their capitals."}
    ],
    "temperature": 0,
    "max_completion_tokens": 500
}

response = requests.post(url, headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))

Create a message

Anthropic’s native Messages API for generating model responses. Supports text and image inputs, and text outputs. Create stateful interactions with the model, using the output of previous responses as input. Extend the model’s capabilities with built-in tools for computer use, text editing, and more. Allow the model access to external systems and data using function calling. Enable extended thinking for complex reasoning tasks.

Default

curl https://api.gmi-serving.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Tell me a three sentence bedtime story about a unicorn."}
    ]
  }'

Streaming

curl https://api.gmi-serving.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "max_tokens": 1024,
    "system": "You are a helpful assistant.",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ],
    "stream": true
  }'

Extended Thinking

curl https://api.gmi-serving.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "max_tokens": 16000,
    "thinking": {
      "type": "enabled",
      "budget_tokens": 10000
    },
    "messages": [
      {"role": "user", "content": "What is the optimal strategy for solving a complex multi-step math problem?"}
    ]
  }'

Functions

curl https://api.gmi-serving.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "What is the weather like in Boston today?"}
    ],
    "tools": [
      {
        "name": "get_current_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"
            },
            "unit": {
              "type": "string",
              "description": "Temperature unit",
              "enum": ["celsius", "fahrenheit"]
            }
          },
          "required": ["location"]
        }
      }
    ]
  }'

Image Input

curl https://api.gmi-serving.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is in this image?"
          },
          {
            "type": "image",
            "source": {
              "type": "url",
              "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
            }
          }
        ]
      }
    ]
  }'

PDF Input

curl https://api.gmi-serving.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is in this document?"
          },
          {
            "type": "document",
            "source": {
              "type": "url",
              "url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
            }
          }
        ]
      }
    ]
  }'

Anthropic SDK (Python)

Install the official Anthropic SDK:
pip install anthropic
Basic Example
from anthropic import Anthropic

# Initialize client with custom base URL
client = Anthropic(
    api_key="$GMI_API_KEY", 
    base_url="https://api.gmi-serving.com"
)

# Basic message
message = client.messages.create(
    model="anthropic/claude-sonnet-4.5",
    max_tokens=100,
    messages=[
        {"role": "user", "content": "What is 2+2? Reply with just the number."}
    ]
)
print(message.content[0].text)
print(f"Usage: input={message.usage.input_tokens}, output={message.usage.output_tokens}")
Streaming Example
from anthropic import Anthropic

client = Anthropic(
    api_key="$GMI_API_KEY",
    base_url="https://api.gmi-serving.com"
)

with client.messages.stream(
    model="anthropic/claude-sonnet-4.5",
    max_tokens=100,
    messages=[
        {"role": "user", "content": "Count from 1 to 5."}
    ]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Claude Code

Claude Code is Anthropic’s agentic coding tool that lives in your terminal. To use Claude Code with this API endpoint, set the following environment variables before starting Claude Code:
export ANTHROPIC_BASE_URL=https://api.gmi-serving.com
export ANTHROPIC_AUTH_TOKEN=$GMI_API_KEY
export API_TIMEOUT_MS=600000
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
export ANTHROPIC_MODEL="anthropic/claude-sonnet-4.5"
export ANTHROPIC_SMALL_FAST_MODEL="anthropic/claude-sonnet-4.5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-4.5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic/claude-opus-4.5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic/claude-haiku-4.5"
After setting these environment variables, you can launch Claude Code and it will automatically use the configured API endpoint.