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 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
  }'

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"

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

In PowerShell, curl may be an alias for Invoke-WebRequest. For behavior consistent with macOS / Linux curl, use curl.exe.

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.