Get started

Quickstart

Make your first request to Reka in a few minutes.

Step 1: Create an API key

  1. Sign in or register if you don’t have an account.
  2. Go to the API keys page.
  3. Select Create key, give it a name, and copy the value. New keys are only shown once, so save it somewhere safe.
  4. Set the key as an environment variable in your terminal:
export REKA_API_KEY="your_api_key"

Step 2: Install the SDK

Reka Gateway is OpenAI-compatible, so you can use the official OpenAI SDK for Python or TypeScript pointed at https://api.reka.ai/v1, or call the REST API directly from any language.

uv init --no-workspace # skip if you already have a project
uv add openai

Step 3: Run your first query

The example below sends a chat completion request to GLM 5.3 Flash and prints the response:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.reka.ai/v1",
    api_key=os.environ["REKA_API_KEY"],
)

response = client.chat.completions.create(
    model="glm5.3-flash",
    messages=[{"role": "user", "content": "What are the top 3 things to do in New York?"}],
)

print(response.choices[0].message.content)

Save the snippet to a file, then run it. (The cURL command runs directly in your terminal.)

uv run main.py

After a few seconds, you should see the response printed to your terminal.

Going further

Try some of these variations to see what else the model can do:

Stream the response

Streaming returns the response token by token as it’s generated, instead of making you wait for the full reply. This is especially helpful with a reasoning model like GLM 5.3 Flash, which works through a problem before answering and can produce a lot of output.

A reasoning model’s response has two parts: the step-by-step thinking, in a reasoning_content field, and the final answer, in content. Set stream=True (Python) or stream: true (TypeScript/cURL) and read delta.reasoning_content and delta.content off each chunk. The thinking streams first, then the answer:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.reka.ai/v1",
    api_key=os.environ["REKA_API_KEY"],
)

stream = client.chat.completions.create(
    model="glm5.3-flash",
    messages=[{"role": "user", "content": "What are the top 3 things to do in New York?"}],
    stream=True,
)

printed_answer_header = False

for chunk in stream:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta

    # Reasoning models stream their thinking in reasoning_content.
    reasoning = getattr(delta, "reasoning_content", None)
    if reasoning:
        print(reasoning, end="", flush=True)

    # The final answer arrives in content.
    if delta.content:
        if not printed_answer_header:
            print("\n\n--- Answer ---\n", flush=True)
            printed_answer_header = True
        print(delta.content, end="", flush=True)

With a non-reasoning model, reasoning_content stays empty and only content is returned, so the same loop works unchanged. DeepSeek V4 Flash, DeepSeek V4 Pro and Qwen3.8 27B behave that way unless you set reasoning_effort; see Reasoning.

Add a system prompt

Prepend a system message to set the model’s tone, role, or constraints:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.reka.ai/v1",
    api_key=os.environ["REKA_API_KEY"],
)

response = client.chat.completions.create(
    model="glm5.3-flash",
    messages=[
        {
            "role": "system",
            "content": "You are a concise travel guide. Answer in two sentences or fewer.",
        },
        {"role": "user", "content": "What are the top 3 things to do in New York?"},
    ],
)

print(response.choices[0].message.content)

Get structured JSON output

Pass a JSON schema via response_format to get parseable JSON back:

import os
from openai import OpenAI
from pydantic import BaseModel

client = OpenAI(
    base_url="https://api.reka.ai/v1",
    api_key=os.environ["REKA_API_KEY"],
)


class Activity(BaseModel):
    name: str
    neighborhood: str
    why: str


class Itinerary(BaseModel):
    city: str
    activities: list[Activity]


response = client.chat.completions.create(
    model="glm5.3-flash",
    messages=[
        {"role": "user", "content": "Suggest 3 things to do in New York."},
    ],
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "Itinerary",
            "schema": Itinerary.model_json_schema(),
        },
    },
)

itinerary = Itinerary.model_validate_json(response.choices[0].message.content)
print(itinerary)

See Structured outputs for model support for json_schema and json_object, along with more guidance on generating structured responses.

Analyze an image

Vision-capable models like GLM 5.3 Flash also accept images. Add an image_url block alongside the text in the user message to ask questions about a picture:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.reka.ai/v1",
    api_key=os.environ["REKA_API_KEY"],
)

response = client.chat.completions.create(
    model="glm5.3-flash",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {"url": "https://v0.docs.reka.ai/_images/000000245576.jpg"},
                },
                {"type": "text", "text": "What animal is this? Answer briefly."},
            ],
        }
    ],
)

print(response.choices[0].message.content)

Next steps