> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# cURL examples

> Copy-paste cURL templates for common tasks

Replace `$OPENPAI_API_KEY` in the examples below with your key to run them.

## Basic chat

```bash theme={null}
curl https://openp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Explain what function calling is"}
    ]
  }'
```

## Streaming response

```bash theme={null}
curl -N https://openp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role": "user", "content": "Tell a 100-word story"}],
    "stream": true
  }'
```

## Vision input

```bash theme={null}
curl https://openp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "What is in the image?"},
        {"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}}
      ]
    }]
  }'
```

## Tool calling

```bash theme={null}
curl https://openp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role": "user", "content": "Today'\''s weather in Shanghai"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get weather for a city",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }]
  }'
```

## JSON structured output

```bash theme={null}
curl https://openp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role": "user", "content": "Return a user JSON with name and age"}],
    "response_format": {"type": "json_object"}
  }'
```

## Claude native protocol

```bash theme={null}
curl https://openp.ai/v1/messages \
  -H "x-api-key: $OPENPAI_API_KEY" \
  -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"}]
  }'
```

## Claude thinking mode

```bash theme={null}
curl https://openp.ai/v1/messages \
  -H "x-api-key: $OPENPAI_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 4096,
    "thinking": {"type": "enabled", "budget_tokens": 8000},
    "messages": [{"role": "user", "content": "Prove Goldbach'\''s conjecture"}]
  }'
```

## Gemini native protocol

```bash theme={null}
curl "https://openp.ai/v1beta/models/gemini-3.1-pro-preview:generateContent" \
  -H "x-goog-api-key: $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "hello"}]}]
  }'
```

## Embeddings

```bash theme={null}
curl https://openp.ai/v1/embeddings \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": ["hello", "world"]
  }'
```

## Rerank

```bash theme={null}
curl https://openp.ai/v1/rerank \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "rerank-multilingual-v3.0",
    "query": "What is a vector database?",
    "documents": ["FAISS is a vector-retrieval library", "Postgres is a relational database"],
    "top_n": 1
  }'
```

## Image generation

```bash theme={null}
curl https://openp.ai/v1/images/generations \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "A red panda eating bamboo, watercolor style",
    "size": "1024x1024",
    "n": 1
  }'
```

## Text to speech

```bash theme={null}
curl https://openp.ai/v1/audio/speech \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Hello from OpenPAI",
    "voice": "alloy"
  }' \
  --output speech.mp3
```

## Speech to text

```bash theme={null}
curl https://openp.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -F file=@audio.mp3 \
  -F model=whisper-1
```

## Model list

```bash theme={null}
curl https://openp.ai/v1/models \
  -H "Authorization: Bearer $OPENPAI_API_KEY"
```

## Account balance

```bash theme={null}
curl https://openp.ai/v1/dashboard/billing/subscription \
  -H "Authorization: Bearer $OPENPAI_API_KEY"
```
