Skip to main content
Conduit.im

cURL Examples

Test and explore the Conduit.im API directly from your terminal with cURL.

Authentication

All requests require a Bearer token in the Authorization header. Use your Conduit.im API key:

curl "https://api.conduit.im/v1/models" \
  -H "Authorization: Bearer YOUR_API_KEY"

Chat Completions

Send a chat completion request and receive the full response:

curl -X POST "https://api.conduit.im/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "What is the capital of France?" }
    ]
  }'

Example response:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1709912400,
  "model": "gpt-4",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 8,
    "total_tokens": 32
  }
}

Streaming

Add "stream": true to your request body and use the -N flag to disable buffering so tokens appear in real time:

curl -N -X POST "https://api.conduit.im/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [
      { "role": "user", "content": "Write a short poem about APIs." }
    ],
    "stream": true
  }'

Note: The -N flag (or --no-buffer) is important for streaming — without it, cURL may buffer output and display everything at once.

List Models

Retrieve the list of available models:

curl "https://api.conduit.im/v1/models" \
  -H "Authorization: Bearer YOUR_API_KEY"

Check Usage

Check your API key usage and remaining balance:

curl "https://api.conduit.im/v1/usage" \
  -H "Authorization: Bearer YOUR_API_KEY"

Common cURL Options

Useful cURL flags when working with the API:

FlagDescription
-vVerbose output — shows request/response headers for debugging
-NDisable buffering — required for real-time streaming
-sSilent mode — hides progress meter, useful when piping output
--max-time 30Set a timeout in seconds for the entire request
-o response.jsonSave the response to a file
| jq .Pipe to jq for pretty-printed, syntax-highlighted JSON

Shell Variables

Set up environment variables to keep your commands clean and your API key out of shell history:

# Add to your ~/.bashrc or ~/.zshrc
export CONDUIT_API_KEY="your-api-key-here"

# Now use the variable in requests
curl -X POST "https://api.conduit.im/v1/chat/completions" \
  -H "Authorization: Bearer $CONDUIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [
      { "role": "user", "content": "Hello!" }
    ]
  }'

Security tip: Avoid pasting your API key directly into commands. Using an environment variable keeps it out of your shell history and makes it easier to rotate keys.

Next Steps