Using the API
Model endpoints
Model endpoints use the OpenAI API format. You can use the official OpenAI SDK or any HTTP client.
Authentication
Send your API key in the apikey header with every request:
apikey: <your-api-key>
Find your endpoint
Open the API Catalog and click a granted model. The detail
page shows its endpoint path, for example
/gemma-2b-instruct/v1/chat/completions, and its model name.
Chat completions
curl https://aifactory-dev.ai-factory.datalab.tuwien.ac.at<endpoint-path> \
-H "apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"model": "<model-name>",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain transformers in one sentence."}
]
}'
Replace <endpoint-path> with the endpoint path from the detail page, and
<model-name> with the model name shown there.
Python example
The OpenAI SDK sends the key in an Authorization header by default. The
platform reads the key from the apikey header, so set that header
explicitly. The SDK needs some value for api_key, but the platform ignores
it.
from openai import OpenAI
client = OpenAI(
base_url="https://aifactory-dev.ai-factory.datalab.tuwien.ac.at<base-path>",
api_key="unused",
default_headers={"apikey": "<your-api-key>"},
)
response = client.chat.completions.create(
model="<model-name>",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
Replace <base-path> with the endpoint path without /chat/completions, for
example /gemma-2b-instruct/v1. Replace <model-name> with the model name
from the detail page.
Other model types
Not every model is a chat model. Embedding and reranking models use other
paths, for example /qwen3-embedding/v1/embeddings and /bge-reranker-v2-m3/v1/rerank. The detail page in the
catalog shows the right path for each model.
Infrastructure services
Infrastructure services, such as the Compute API, have their own REST
interface. The full reference is in the
Swagger UI.
Authentication is the same: use the apikey header. The Compute API is
limited during the pilot, see Limitations.