Overview

How the API is organised: the base URL, the two API styles, the other endpoints and the conventions they share.

Base URL

Every endpoint is served over HTTPS under your API base URL: API_BASE_URL. The examples read it from a variable:

shell
export KEYDAN_API_KEY="YOUR_API_KEY"
export KEYDAN_API_BASE="API_BASE_URL"

Two API styles

Use whichever format your code already speaks. Both reach the same models with the same keys, limits and prices.

API styles
StyleEndpointUse it when
Messages APIPOST /v1/messagesyour client uses the Messages format: content blocks, system as a field, max_tokens required
Chat Completions APIPOST /v1/chat/completionsyour client uses the Chat Completions format: messages with roles, choices in the answer

The model catalogue shows the styles each model can be called with.

Other endpoints

Other endpoints
EndpointWhat it does
GET /v1/modelsthe models your key may use (model ids)
GET /v1/billing/balanceyour balance (balance and billing)
GET /public/v1/modelsthe public catalogue with prices, no key needed
GET /public/v1/plansthe subscription plans, no key needed
GET /public/v1/statusthe live status, no key needed (status page)
GET /public/v1/status/historythe last 24 hours of each API format in half-hour steps, no key (the bars on the status page)

Conventions

  • Requests and answers are JSON in UTF-8; streamed answers are server-sent events.
  • Every answer carries x-request-id. Quote it when you contact support.
  • Errors have one shape per API style and a stable error.code: see errors.
  • Request bodies have a size limit; a larger body is refused with 413.
  • The version is in the path (/v1). Fields may be added to answers at any time; read them leniently.