Skip to content

Examples

All examples use the default base URL https://puter-api.x0root.workers.dev. Replace qp-your-api-key with your real key.

Simple Non-Streaming Request

curl https://puter-api.x0root.workers.dev/v1/chat/completions \
  -H "Authorization: Bearer qp-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "router",
    "messages": [
      { "role": "user", "content": "Say hello in one sentence." }
    ],
    "context": false,
    "max_tokens": 80
  }'

Use prompt Shortcut

curl https://puter-api.x0root.workers.dev/v1/chat/completions \
  -H "Authorization: Bearer qp-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Give me three project name ideas.",
    "context": false
  }'

Start a New Memory Chat

curl https://puter-api.x0root.workers.dev/v1/chat/completions \
  -H "Authorization: Bearer qp-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "router",
    "new_chat": true,
    "context": true,
    "messages": [
      { "role": "user", "content": "Remember that my app is called Skyforge." }
    ]
  }'

Save the returned chat_id — you'll need it to continue this conversation later.

Continue a Memory Chat

curl https://puter-api.x0root.workers.dev/v1/chat/completions \
  -H "Authorization: Bearer qp-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "router",
    "chat_id": "chat_550e8400-e29b-41d4-a716-446655440000",
    "context": true,
    "messages": [
      { "role": "user", "content": "What is my app called?" }
    ]
  }'

Clear Memory For A Chat

Send context: false with the chat id:

curl https://puter-api.x0root.workers.dev/v1/chat/completions \
  -H "Authorization: Bearer qp-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "chat_550e8400-e29b-41d4-a716-446655440000",
    "context": false,
    "messages": [
      { "role": "user", "content": "Start fresh. Say hello." }
    ]
  }'

This clears/skips memory for that chat before answering.

Streaming Request

curl -N https://puter-api.x0root.workers.dev/v1/chat/completions \
  -H "Authorization: Bearer qp-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "router",
    "stream": true,
    "messages": [
      { "role": "user", "content": "Write a tiny story." }
    ]
  }'

Tip

Use -N (no buffering) with curl so SSE chunks print as they arrive.