Skip to content

cURL Examples

Call the Claudexia API directly from the command line using cURL. Both Anthropic and OpenAI request formats are supported.

Anthropic format

bash
curl https://api.claudexia.tech/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: sk_cdx_YOUR_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4.5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, Claude!"}
    ]
  }'

OpenAI format

bash
curl https://api.claudexia.tech/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk_cdx_YOUR_KEY" \
  -d '{
    "model": "claude-sonnet-4.5",
    "messages": [
      {"role": "user", "content": "Hello, Claude!"}
    ]
  }'

Streaming

Add "stream": true and use --no-buffer to see tokens as they arrive.

Anthropic format

bash
curl --no-buffer https://api.claudexia.tech/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: sk_cdx_YOUR_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4.5",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a short poem about coding."}
    ]
  }'

OpenAI format

bash
curl --no-buffer https://api.claudexia.tech/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk_cdx_YOUR_KEY" \
  -d '{
    "model": "claude-sonnet-4.5",
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a short poem about coding."}
    ]
  }'

List models

bash
curl https://api.claudexia.tech/v1/models \
  -H "Authorization: Bearer sk_cdx_YOUR_KEY"

Model info

bash
curl https://api.claudexia.tech/v1/models/info \
  -H "Authorization: Bearer sk_cdx_YOUR_KEY"