Skip to content

Quickstart

Create an API key, send your first request with cURL, Python, TypeScript or Go, point the OpenAI SDK at Lykia and stream the response.

Markdown
On this page

This page takes you from a new account to your first response. The Lykia API uses the OpenAI Chat Completions format, so if you have called the OpenAI API before, the requests and responses below will look familiar.

1. Create an API key

  1. Create an account and set up your company. A project called "Default" is created for you along with it.
  2. Open that project in the dashboard and create a new key under API keys.
  3. Copy the key straight away. It starts with lyk-v1- and is shown once, at creation time. Lykia does not store the key itself, so it cannot show it to you again later.

All examples read the key from the LYKIA_API_KEY environment variable:

Terminal
export LYKIA_API_KEY="<LYKIA_API_KEY>"

2. Add credits, or add your own provider key

Choose one of two ways to pay for requests:

  • Add credits. On the Credits page of the dashboard you top up a USD balance for your company and pay on Efespay's secure payment page, which opens in a new tab. Your first top-up also moves the company from the Free plan to Standard, the plan that allows paid models. What gets deducted from the balance: Credits and billing.
  • Add your own provider key (BYOK). Under Provider keys in your project, add your own key for a provider such as OpenAI, Anthropic or Google AI Studio. Requests to that provider's models then go out with your key and the provider bills you; this works on the Free plan too. See Bring your own key (BYOK).

A request sent with no credits and no provider key returns 402. Error bodies, and which code comes back when, are described in Errors.

3. Send your first request

The request below sends a single user message to openai/gpt-4o-mini. If you added your own provider key in step 2, use a model from that provider instead (for example anthropic/claude-sonnet-4.5 with an Anthropic key). Model ids take the form author/model; the Models page shows how to list them all.

curl https://api.getlykia.com/v1/chat/completions \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Explain what an AI gateway does in one sentence." }
    ]
  }'

The response uses the OpenAI format, with a few fields added by Lykia:

200 OK
{
  "id": "gen-1795373724-GNtDgXTt5L42PjqQ",
  "object": "chat.completion",
  "created": 1795373724,
  "model": "openai/gpt-4o-mini",
  "provider": "openai",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "An AI gateway sits between your application and model providers, giving you one API to call while it routes, bills and logs each request."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 17,
    "completion_tokens": 27,
    "total_tokens": 44,
    "cost": 0.000019,
    "is_byok": false,
    "cost_details": {
      "upstream_cost": 0.000019,
      "platform_fee": 0,
      "is_byok": false
    },
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    }
  },
  "system_fingerprint": "fp_560af6e559"
}
  • id: Lykia's id for the request (it starts with gen-). The same id comes back in the X-Generation-Id response header. Use it with GET /generation to look up cost and timing details.
  • model: the model that actually served the request.
  • provider: the id of the provider that served the request (for example openai).
  • usage.cost: what this request cost, in USD. If you pay with credits, this is the amount taken from your balance; on a request sent with your own provider key, usage.is_byok is true.

Use the OpenAI SDK

OpenAI's official SDKs work with Lykia unchanged. When you create the client, set the base URL to https://api.getlykia.com/v1 and the API key to your Lykia key; the rest of your code stays the same. Any model id from the catalog works, and the example below calls an Anthropic model.

import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.getlykia.com/v1",
    api_key=os.environ["LYKIA_API_KEY"],
)

completion = client.chat.completions.create(
    model="anthropic/claude-sonnet-4.5",
    messages=[{"role": "user", "content": "Write a haiku about load balancers."}],
)
print(completion.choices[0].message.content)

Stream the response

To receive the answer as it is generated instead of waiting for all of it, add "stream": true to the request. Lykia sends the response as Server-Sent Events, and the SDKs parse the stream for you.

curl -N https://api.getlykia.com/v1/chat/completions \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-2.5-flash",
    "stream": true,
    "messages": [{ "role": "user", "content": "Count from 1 to 5, one number per line." }]
  }'

Usage and cost arrive in the last chunk of the stream. The Streaming guide covers the format and what happens if you stop reading halfway.

Next steps

  • How Lykia works: see how projects, keys and credits come together on every request.
  • Model fallbacks: move on to the next model automatically when one cannot answer.
  • Errors: know which errors to retry and which mean the request needs fixing.
  • POST /chat/completions: every field of the request body.