Integrations
FastAPI
Call the Apertis API from a FastAPI route with the OpenAI Python SDK.
Add a /chat route to a FastAPI app that returns a chat completion from Apertis, using the OpenAI Python SDK.
Install
pip install openai fastapi "uvicorn[standard]"Set your API key
Create a key in Settings → API Keys, then export it:
export APERTIS_API_KEY="sk-your-api-key"Minimal app
main.py:
import os
from fastapi import FastAPI
from openai import OpenAI
app = FastAPI()
client = OpenAI(
base_url="https://api.apertis.ai/v1",
api_key=os.environ["APERTIS_API_KEY"],
)
@app.get("/chat")
def chat(q: str = "Hello! What can you do?"):
completion = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": q}],
)
return {"text": completion.choices[0].message.content}Run and test
uvicorn main:app --reload
curl "http://127.0.0.1:8000/chat?q=Say+hi"The SDK sends Authorization: Bearer with your key to https://api.apertis.ai/v1. Pick any model ID from the Models page.
Next steps
- Quick Start: create an account and your first request
- API Keys: create and rotate keys
- Chat Completions: every request field
- Messages API: the Anthropic-style endpoint
- Error codes: a
401means the key is missing or wrong