People who develop

Connecting a program to an agent: the key and the two calls

A company program, such as the business software, a script or the back end of a website, can ask questions of an LLMON agent. The request has the same shape as OpenAI’s, so the libraries you already use work.

3-minute read

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.

  1. 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.
  2. The administrator chooses the agent, names the key and, optionally, sets an expiry date; then presses Issue the key.
  3. 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.

The two calls
CallWhat it does
GET /v1/modelsReturns the key’s only model: its id is the value of model.
POST /v1/chat/completionsThe 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

A question 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:

A question in Python
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.

LLMON at work on documents, in a live demonstration.

In a 30-minute video call we show you the chat, the knowledge bases and the admin dashboard, and answer your company’s questions.

Book a demo

A 30-minute video call: LLMON live on sample documents, with answers to your questions.