Integrations
Flask
Call the Apertis API from a Flask route with the OpenAI Python SDK.
Add a /chat route to a Flask app that returns a chat completion from Apertis, using the OpenAI Python SDK.
Install
pip install openai flaskSet your API key
Create a key in Settings → API Keys, then export it:
export APERTIS_API_KEY="sk-your-api-key"Minimal app
app.py:
import os
from flask import Flask, jsonify, request
from openai import OpenAI
app = Flask(__name__)
client = OpenAI(
base_url="https://api.apertis.ai/v1",
api_key=os.environ["APERTIS_API_KEY"],
)
@app.get("/chat")
def chat():
q = request.args.get("q", "Hello! What can you do?")
completion = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": q}],
)
return jsonify(text=completion.choices[0].message.content)Run and test
flask --app app run --port 8000
curl "http://127.0.0.1:8000/chat?q=Say+hi"The app runs on port 8000 because macOS reserves Flask's default port 5000 for AirPlay Receiver.
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