How to use chat.ai.e-infra.cz via API
Generating an API token
- Log in to https://chat.ai.e-infra.cz/ via browser using your Metacentrum credentials. If you don't have one, here is how to get access.
- At chat.ai.e-infra.cz, on the top right corner, click on the profile icon and open
Settings. - Navigate to
Accountand click onAPI keys (display). - Ignore JWT token and select API key and either generate new or display existing.
- Copy the generated API key and store it securely.
- Use this key in API requests to authenticate and access Open-WebUI services.
API endpoint is: https://llm.ai.e-infra.cz/v1/.
Listing available models
As the models are named differently in the web UI, it is necessary to list the ones that are available via the API. This can be done using the following command:
export EINFRA_AI_TOKEN="..." curl -H "Authorization: Bearer $EINFRA_AI_TOKEN" https://llm.ai.e-infra.cz/v1/models | jq .data[].id
Where EINFRA_AI_TOKEN refers to the e-infra API key acquired in previous steps. It is also a good way of checking whether the token is valid. The output should be similar to this:
"gpt-oss-120b" "deepseek-r1" "qwen3-coder" "qwen2.5-coder:32b-instruct-q8_0" "medgemma:27b-it" ...
Inference
As the E-Infra uses OpenAI-compatible server, you can use any Python framework that is capable of HTTP requests. Several options for inspiration are:
- openai-python: the official implementation for OpenAI API.
- PydanticAI: an extensive toolkit that supports advanced applications.
- requests: low-level approach, recommended when you want custom behavior.
Example using openai-python
import os
import openai
MODEL = "deepseek-v3.2-thinking"
BASE_URL = "https://llm.ai.e-infra.cz/v1/"
client = openai.OpenAI(
# using environment variables are one of the safer ways to pass your API keys
api_key=os.environ["EINFRA_AI_TOKEN"],
#openai uses chatgpt url as default - we need to override it here
base_url=BASE_URL,
)
response = client.chat.completions.create(
#here you paste the selected model
model=MODEL,
messages=[
{"role": "system", "content": "Talk like a pirate."},
{
"role": "user",
"content": "What is a mast?",
},
],
)
print(response.choices[0].message.content)
References
Official documentation: https://docs.cerit.io/en/docs/ai-as-a-service/chat-ai







