The key
A key is your program’s password for a single agent: it works for that agent and no other. An office administrator issues it in the Control Panel, on the API keys page.
- The agent and its collections must be shared, read-only, with the chat user “API agenti”. The API keys page says for each agent whether it is ready and, if not, what to share.
- The administrator chooses the agent, names the key and, optionally, sets an expiry date; then presses Issue the key.
- The key is shown only once, on the page that displays it together with ready-made examples. Keep it like a password: the unit stores only a fingerprint of it, so it cannot be recovered, only replaced.
A key can be revoked at any time from the same page: from the next call on, the service answers 401. If a key ends up where it should not, have it revoked at once.
The address and the two calls
The base address is https://<your-unit-address>/v1: the administrator gives it to you together with the key.
| Call | What it does |
|---|---|
GET /v1/models | Returns the key’s only model: its id is the value of model. |
POST /v1/chat/completions | The question and the answer, as with OpenAI, also streamed piece by piece with "stream": true. |
The full contract, readable by OpenAPI tools, sits at the same base address, under openapi.json.
Examples
With curl
curl https://<your-unit-address>/v1/chat/completions \
-H "Authorization: Bearer <your-key>" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Summarise the returns policy in three lines."}]}' The answer is a chat.completion object: the text is in choices[0].message.content. The model field can be left out: the key’s model always applies.
In Python
With the openai library (pip install openai), reading the key from an environment variable rather than writing it in the code:
import os
import openai
client = openai.OpenAI(
base_url="https://<your-unit-address>/v1",
api_key=os.environ["LLMON_API_KEY"], # <your-key>
)
model = client.models.list().data[0].id
answer = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "Summarise the returns policy in three lines."}],
)
print(answer.choices[0].message.content) To continue a dialogue, send the previous messages again in messages: the service remembers nothing between one call and the next. Limits, ignored fields and error codes: limits and errors.