Skip to main content
Pre-launch. fremai is not open for signups yet. These docs describe the launch API and are subject to change. fremai.eu →

Quickstart

fremai is OpenAI-compatible. If you already call the OpenAI API, you change two things — the base URL and the API key — and pick a fremai model by name. Nothing else in your code changes.

What you need

  1. A fremai API key. Create one in the console at app.fremai.eu. Keys look like sk-fremai-….
  2. The base URL: https://api.fremai.eu/v1.
  3. A model id from the catalog — e.g. glm-5.2.

Using opencode? Skip the key entirely — run fremai login and the auth plugin supplies a short-lived key for you. See the opencode guide.

1. Set your key

Keep the key out of your source. Put it in an environment variable:

export FREMAI_API_KEY="sk-fremai-…"

2. Your first call — curl

curl https://api.fremai.eu/v1/chat/completions \
  -H "Authorization: Bearer $FREMAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.2",
    "messages": [
      {"role": "user", "content": "Say hello from fremai in one sentence."}
    ]
  }'

You get back a standard OpenAI chat.completion object — choices[0].message.content holds the reply, and usage reports the token counts you are billed on.

3. The same call — OpenAI SDK

The OpenAI SDKs let you override the base URL. That is all it takes.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.fremai.eu/v1",
    api_key="sk-fremai-…",  # or os.environ["FREMAI_API_KEY"]
)

resp = client.chat.completions.create(
    model="glm-5.2",
    messages=[{"role": "user", "content": "Say hello from fremai in one sentence."}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.fremai.eu/v1",
  apiKey: process.env.FREMAI_API_KEY, // "sk-fremai-…"
});

const resp = await client.chat.completions.create({
  model: "glm-5.2",
  messages: [{ role: "user", content: "Say hello from fremai in one sentence." }],
});
console.log(resp.choices[0].message.content);

4. Stream the response

Set stream: true and read Server-Sent Events (chat.completion.chunk objects, terminated by data: [DONE]) — identical to OpenAI streaming:

stream = client.chat.completions.create(
    model="glm-5.2",
    messages=[{"role": "user", "content": "Write a haiku about Europe."}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

Next steps