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 →
OpenAI SDK

OpenAI SDK

The official OpenAI SDKs let you override the base URL, so fremai is a two-line change: set base_url / baseURL to https://api.fremai.eu/v1 and use your sk-fremai-… key. Everything else — request shapes, streaming, error handling — is unchanged.

Python

pip install openai
import os
from openai import OpenAI

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

resp = client.chat.completions.create(
    model="glm-5.2",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Summarise the EU AI Act in two sentences."},
    ],
)
print(resp.choices[0].message.content)

Streaming

stream = client.chat.completions.create(
    model="glm-5.2",
    messages=[{"role": "user", "content": "Count to five, one number per line."}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

Embeddings

emb = client.embeddings.create(
    model="<embedding-model-id>",  # see GET /models for ids available to your key
    input=["EU-sovereign inference", "OpenAI-compatible API"],
)
print(len(emb.data), "vectors")

JavaScript / TypeScript

npm install openai
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: "system", content: "You are a concise assistant." },
    { role: "user", content: "Summarise the EU AI Act in two sentences." },
  ],
});
console.log(resp.choices[0].message.content);

Streaming

const stream = await client.chat.completions.create({
  model: "glm-5.2",
  messages: [{ role: "user", content: "Count to five, one number per line." }],
  stream: true,
});
for await (const chunk of stream) {
  const delta = chunk.choices[0]?.delta?.content;
  if (delta) process.stdout.write(delta);
}

Notes

  • Model ids come from the catalog or GET /models. Pass the id as the model field.
  • Keep your key server-side. Do not embed sk-fremai-… in browser or mobile clients — proxy through your backend.
  • Base URL includes /v1. The SDK appends /chat/completions to whatever base URL you give it; the ingress also accepts the bare-root form for clients configured without /v1.