Skip to content

Start

Quickstart

Working examples in the ways people actually call this API. Every snippet targets the credit surface, so swap the base URL if you hold a token key.

Setup (permalink)

You need a key. Put it in your environment rather than in source, and every example below picks it up without further editing.

ShellReplace with the key you were issued
export KORLOGIC_API_KEY="kl_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Install a client if you want one. curl and fetch need nothing.

Shell
pip install openai      # OpenAI-compatible clients
pip install anthropic   # Anthropic Messages clients

Your first call (permalink)

A single chat completion against claude-sonnet-5. Any id from the model catalogue works the same way.

Shell
curl https://api.korlogic.com/v1/chat/completions \
  -H "Authorization: Bearer $KORLOGIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [{ "role": "user", "content": "Say hello in five words." }]
  }'

The response is the standard OpenAI chat completion object, including the usage block. That block is what your key is billed against, and what shows up in the usage checker.

Streaming (permalink)

Set stream: true and read server-sent events. The gateway forwards the stream byte for byte, so any SDK’s streaming helper works unchanged.

Shell
curl -N https://api.korlogic.com/v1/chat/completions \
  -H "Authorization: Bearer $KORLOGIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "stream": true,
    "messages": [{ "role": "user", "content": "Count to five." }]
  }'
  • You do not need to set stream_options. On the OpenAI-style paths (/chat/completions, /responses, /completions) usage reporting is requested on your behalf, so a streamed request is metered as accurately as a buffered one.
  • Billing settles when the stream finishes, so a streamed request appears in the usage checker a moment after its last token.
  • Use curl -N when testing by hand. Without it curl buffers the whole response and streaming looks like it did nothing.

Anthropic Messages (permalink)

The Anthropic format is served on the same key at /messages. Two things it needs that Chat Completions does not: max_tokens in the body, which is required, and the anthropic-version header. The SDKs send the version header for you, so only raw HTTP callers have to add it.

Shell
curl https://api.korlogic.com/v1/messages \
  -H "x-api-key: $KORLOGIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 256,
    "messages": [{ "role": "user", "content": "Say hello in five words." }]
  }'

Streaming works the same way, with the SDK’s own helper.

Python
with client.messages.stream(
    model="claude-sonnet-5",
    max_tokens=256,
    messages=[{"role": "user", "content": "Count to five."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Listing models (permalink)

The catalogue endpoint returns the upstream model list in OpenAI list format. It is the quickest way to confirm that a key and a base URL agree, because it needs no request body.

Shell
curl https://api.korlogic.com/v1/models \
  -H "Authorization: Bearer $KORLOGIC_API_KEY"

It reports the catalogue, not your permissions. If your key has a model allowlist, this response is still the full list. See Models.

If it fails (permalink)

Quickstart troubleshooting
You seeUsually means
401A mistyped or truncated key, or the right key on the wrong base URL. Check which surface your key belongs to.
402Out of credit, or out of token budget. Confirm in the usage checker.
403The key is suspended, expired, or not scoped to the model you asked for.
404The path was built wrong, usually a doubled or a missing /v1.
400 on Messagesmax_tokens is missing. The Anthropic Messages API requires it on every request.

Every status and code, with what to do about each, is on Errors.