Integrations
Django
Call the Apertis API from a Django view with the OpenAI Python SDK.
Add a /chat/ view to a Django project that returns a chat completion from Apertis, using the OpenAI Python SDK.
Install
pip install openai django
django-admin startproject mysite
cd mysiteSet your API key
Create a key in Settings → API Keys, then export it:
export APERTIS_API_KEY="sk-your-api-key"Minimal view
Replace the project's urls.py with:
mysite/urls.py:
import os
from django.contrib import admin
from django.http import JsonResponse
from django.urls import path
from openai import OpenAI
client = OpenAI(
base_url="https://api.apertis.ai/v1",
api_key=os.environ["APERTIS_API_KEY"],
)
def chat(request):
q = request.GET.get("q", "Hello! What can you do?")
completion = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": q}],
)
return JsonResponse({"text": completion.choices[0].message.content})
urlpatterns = [
path("admin/", admin.site.urls),
path("chat/", chat),
]Run and test
python manage.py runserver
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