51cowork APIDocs
Open docs navigation

SDKs

cURL request examples

cURL is the smallest smoke test for isolating gateway, Key, model, and protocol configuration.

Quick answer

List models first, send one non-streaming request, then move the same values to an SDK, CLI, or IDE.

Use
Smoke test
Auth
Bearer / x-api-key
Model
/v1/models
Stream
-N + stream
01

Set variables

Terminalbash
export COWORK_GATEWAY_URL="https://api.51cowork.com"
export COWORK_API_KEY="<key-from-dashboard>"
export COWORK_MODEL="<model-from-v1-models>"
02

List models

GET /v1/modelsbash
curl "https://api.51cowork.com/v1/models" \
  -H "Authorization: Bearer <key-from-dashboard>"
03

Three request formats

Anthropic Messagesbash
curl "https://api.51cowork.com/v1/messages" \
  -H "x-api-key: <key-from-dashboard>" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "<model-from-v1-models>",
    "max_tokens": 256,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
OpenAI Chatbash
curl "https://api.51cowork.com/v1/chat/completions" \
  -H "Authorization: Bearer <key-from-dashboard>" \
  -H "Content-Type: application/json" \
  -d '{"model":"<model-from-v1-models>","messages":[{"role":"user","content":"Hello"}]}'
OpenAI Responsesbash
curl "https://api.51cowork.com/v1/responses" \
  -H "Authorization: Bearer <key-from-dashboard>" \
  -H "Content-Type: application/json" \
  -d '{"model":"<model-from-v1-models>","input":"Hello"}'