ПОСТ /в1/мессагес

Антхропиц Мессагес АПИ за ћаскање, стримовање, визију, алате, кеширање и размишљање.

ПОСТ /в1/мессагес

Главна крајња тачка компатибилна са антропизмом. Подржава стримовање, брзо кеширање, визију, употребу алата и проширено размишљање када га подржава изабрани модел.

Аутентификација

x-api-key: mg_live_...\nanthropic-version: 2023-06-01\ncontent-type: application/json

Минимални захтев

curl https://api.model-gate.com/v1/messages \
  -H "x-api-key: mg_live_..." \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-4.8",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Напредни захтев

{
  "model": "claude-opus-4.8",
  "max_tokens": 4096,
  "system": "You are a coding assistant.",
  "thinking": {"type": "enabled", "budget_tokens": 8000},
  "messages": [{"role": "user", "content": "Find the bug in this code."}],
  "tools": [{
    "name": "search_files",
    "description": "Search project files",
    "input_schema": {"type": "object", "properties": {"q": {"type": "string"}}}
  }]
}

Висион

{
  "model": "claude-opus-4.8",
  "max_tokens": 1024,
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "What is shown in this image?"},
      {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "..."}}
    ]
  }]
}

Промпт кеширање

{
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Large reusable context...", "cache_control": {"type": "ephemeral"}},
      {"type": "text", "text": "New question"}
    ]
  }]
}

Стреаминг

Сет "stream": true. Одговор се враћа као догађаји послани сервером.

Одговор

{
  "id": "msg_...",
  "type": "message",
  "role": "assistant",
  "model": "claude-opus-4.8",
  "content": [{"type": "text", "text": "Hello!"}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 12, "output_tokens": 8}
}

Структура захтева и одговора прати Антхропиц Мессагес АПИ. Постојећи антропски пакети за развој софтвера обично захтевају само base_url променити.