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
- A fremai API key. Create one in the console at app.fremai.eu. Keys look like
sk-fremai-…. - The base URL:
https://api.fremai.eu/v1. - A model id from the catalog — e.g.
glm-5.2.
Using opencode? Skip the key entirely — run
fremai loginand 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
- Wire up your client of choice in the setup guides — opencode, OpenAI SDK, curl, LangChain.
- Browse the model catalog.
- Read the full API reference.
- Coming from OpenAI or Anthropic? See the migration guide.