Skip to content

curl Testing ​

curl requires no SDK installation, making it ideal for first-time CoreRouter configuration verification and client troubleshooting.

Basic Call ​

bash
export COREROUTER_API_KEY="sk-xxxxxxxxxxxxxxxx"

curl https://api.corerouter.cloud/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COREROUTER_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-5",
    "messages": [
      {
        "role": "user",
        "content": "Hello, please introduce yourself."
      }
    ]
  }'

Streaming Output ​

bash
curl --no-buffer https://api.corerouter.cloud/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COREROUTER_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-5",
    "messages": [
      {"role": "user", "content": "Introduce CoreRouter in three sentences."}
    ],
    "stream": true
  }'

--no-buffer disables curl's own output buffering so events can be observed as they arrive. It does not remove buffering in upstream services, proxies, or clients.

Multi-Turn Conversation ​

bash
curl https://api.corerouter.cloud/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COREROUTER_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-5",
    "messages": [
      {"role": "user", "content": "Hello"},
      {"role": "assistant", "content": "Hello! How can I help you?"},
      {"role": "user", "content": "Please write a Python hello function."}
    ]
  }'

Query Model List ​

bash
curl https://api.corerouter.cloud/v1/models \
  -H "Authorization: Bearer $COREROUTER_API_KEY"

Responses API ​

Responses API is suitable for Codex, Agents, and some applications requiring unified event streams. It requires the selected Model ID to support Responses; regular chat models may not work.

bash
curl https://api.corerouter.cloud/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COREROUTER_API_KEY" \
  -d '{
    "model": "responses-model-id",
    "input": "Introduce CoreRouter in three sentences."
  }'

Anthropic Messages ​

Claude Code or Anthropic-style clients typically use https://api.corerouter.cloud as the Base URL, with the actual request path being /v1/messages.

bash
curl https://api.corerouter.cloud/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $COREROUTER_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'

Gemini-Style Interface ​

bash
curl "https://api.corerouter.cloud/v1beta/models/gemini-model-id:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $COREROUTER_API_KEY" \
  -d '{
    "contents": [
      {
        "parts": [
          {"text": "Hello"}
        ]
      }
    ]
  }'

Windows PowerShell ​

powershell
$env:COREROUTER_API_KEY="sk-xxxxxxxxxxxxxxxx"

$body = @{
  model = "claude-sonnet-4-5"
  messages = @(@{ role = "user"; content = "Hello" })
} | ConvertTo-Json -Depth 10

$response = Invoke-RestMethod `
  -Uri "https://api.corerouter.cloud/v1/chat/completions" `
  -Method Post `
  -Headers @{ Authorization = "Bearer $env:COREROUTER_API_KEY" } `
  -ContentType "application/json; charset=utf-8" `
  -Body ([System.Text.Encoding]::UTF8.GetBytes($body))

$response | ConvertTo-Json -Depth 20

This example constructs JSON and sends UTF-8 using native PowerShell commands, avoiding differences between Windows PowerShell 5.1 and PowerShell 7 when passing JSON quotes to external programs. If using curl separately, write curl.exe explicitly: some PowerShell versions alias curl to Invoke-WebRequest.

Common Errors ​

  • 401 Unauthorized: API Key is invalid, expired, disabled, or Header is missing Bearer.
  • 400 Bad Request: JSON format error, missing model, or model ID does not exist.
  • 403 Forbidden: API Key permissions, IP whitelist, model permissions, or account status not met.
  • 429 Too Many Requests: Request rate too high, reduce concurrency or retry later.
  • 404 Not Found: Check if the path is correct, especially /v1/responses, /v1/messages, and Gemini paths.

Released under the MIT License.