Get started

Endpoints

Choose the request format your application already uses. Straitly accepts OpenAI Chat Completions and Anthropic Messages through the same base URL and API key.

Base URL: https://api.straitly.ai/v1

Authentication

Send your Straitly key in the Authorization header as a bearer token. The examples below read it from STRAITLY_API_KEY in your terminal environment. Create a key on the API keys page. Keep it on your server, not in browser code or a public repository.

export STRAITLY_API_KEY="YOUR_STRAITLY_API_KEY"
bash

For POST requests, send a JSON body with Content-Type: application/json.

Chat completions

POST /chat/completions

Use this with the OpenAI SDK or a client that accepts an OpenAI-compatible base URL. Send a model ID and a messages array containing the conversation.

curl https://api.straitly.ai/v1/chat/completions \
  -H "Authorization: Bearer $STRAITLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'
bash

Read the reply from choices[0].message.content. Token counts are returned in usage. Add "stream": true for incremental output; see the streaming guide for chunk handling.

Messages

POST /messages

Use this for Anthropic-format requests. Include model, messages, and max_tokens, the maximum number of output tokens to generate. A system prompt belongs in the top-level system field.

curl https://api.straitly.ai/v1/messages \
  -H "Authorization: Bearer $STRAITLY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 256,
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'
bash

The reply is an array of content blocks. For text blocks, read text; tool-use blocks have a different shape. Token counts are in usage.

Using the Anthropic SDK? Set its base URL to https://api.straitly.ai. The SDK adds /v1/messages itself. The OpenAI SDK uses the full base URL above, including /v1. SDK examples

List models

GET /models

Fetch the live model list before choosing a model. This request has no body. Use an entry’s id from the response’s data array in your inference request.

curl https://api.straitly.ai/v1/models \
  -H "Authorization: Bearer $STRAITLY_API_KEY"
bash

Browse prices and capabilities on the models page. Support for tools, images, and structured outputs depends on the model you choose.

Errors and next steps

  • 401: check that you supplied an active Straitly key.
  • 402: check your balance and the key’s spending cap.
  • 404 model_not_found: check the ID against /models.
  • 429: wait for the duration in Retry-After before retrying.

See Errors & limits for error codes and budgets, or Logs & exports to inspect requests and charges.