Skip to content

Talk to the world itself (model world) or an agent: the one named as the model, or the one whose base URL this is

POST
/api/v1/openai/v1/chat/completions
curl --request POST \
--url http://localhost:11044/api/v1/openai/v1/chat/completions \
--header 'Content-Type: application/json' \
--header 'X-Embabel-Api-Key: <X-Embabel-Api-Key>' \
--data '{ "embabel_conversation": "example", "embabel_evidence": true, "embabel_observing": true, "embabel_realms": [ "example" ], "embabel_verbosity": "example", "max_completion_tokens": 1, "max_tokens": 1, "messages": [ { "content": "example", "role": "example" } ], "model": "example", "stream": true, "temperature": 1, "user": "example" }'

An OpenAI chat request. model names the agent on /openai/v1, or is world for the world itself, and is ignored on an agent’s own base URL. messages is the history (string content, or the text parts of a part list) and needs at least one non-blank user message, or it is a 400. stream: true answers server-sent chunks, the whole answer arriving as one. temperature and max_completion_tokens (else max_tokens) are held to the agent’s declared sampling bounds and ignored without them, and for the world; user keeps a client’s end users’ chats apart. Embabel extensions: embabel_conversation, a caller-chosen conversation id; embabel_realms, narrowing to some of the agent’s realms (ignored for the world); embabel_verbosity, terse, normal or full; embabel_observing, refusing and reporting every effect the turn attempts (a 400 for the world, which has no routine to observe); embabel_evidence, adding an embabel block with the conversation, run, raised requests and refusals. Other fields, such as tools, are ignored

Media typeapplication/json

An OpenAI chat completion request to an agent, sent to POST /openai/v1/chat/completions or /agents/{name}/v1/chat/completions. Fields OpenAI defines and this does not list (tools, top_p…) are ignored; the embabel_ fields are this server’s own.

object
embabel_conversation

Conversation name the caller chooses: the same name, from any client, continues the same conversation with this agent. Absent or blank, the conversation is recognised from the user and how the history began.

string
embabel_evidence

True adds the embabel evidence object to the response (on the final chunk when streaming); otherwise it is absent

boolean
embabel_observing

True refuses every effect the agent attempts this turn, even if it is on duty, and reports what it would have done

boolean
embabel_realms

Realm names to narrow the conversation to, from among the agent’s own; never adds one. Absent or empty keeps all of them.

Array<string>
embabel_verbosity

Reply length: terse asks for a sentence or two, full for a full answer, normal (or absent, or any other value) for neither. Case-insensitive.

string
max_completion_tokens

Reply length cap in tokens, preferred over max_tokens; capped at the agent’s declared most, ignored when it declares none

integer format: int32
max_tokens

Reply length cap in tokens, used when max_completion_tokens is absent; capped at the agent’s declared most, ignored when it declares none

integer format: int32
messages
required

The conversation so far, oldest first, as OpenAI clients resend it each time. The newest user message is the turn answered; earlier user and assistant messages are context. At least one non-blank user message is required.

Array<object>

One message of an OpenAI chat request’s history

object
content

A string, or a list of content parts of which only the {type: text, text} ones are read, joined by newlines; anything else reads as empty

role
required

User or assistant; messages with any other role, such as system, are not read

string
model

Name of the agent to talk to, as listed by GET /openai/v1/models, or world for the world itself; ignored on an agent’s own base URL, where the path names the agent

string
stream

True answers as server-sent chat.completion.chunk events ending in [DONE]; the whole answer arrives as one content chunk. Absent or false answers one chat.completion.

boolean
temperature

Sampling temperature, clamped into the range the agent declares; ignored when the agent declares none

number format: double
user

The client’s own end-user id, when it sends one; part of how a conversation is recognised, so two of its users’ chats stay apart

string

Example generated

{
"embabel_conversation": "example",
"embabel_evidence": true,
"embabel_observing": true,
"embabel_realms": [
"example"
],
"embabel_verbosity": "example",
"max_completion_tokens": 1,
"max_tokens": 1,
"messages": [
{
"content": "example",
"role": "example"
}
],
"model": "example",
"stream": true,
"temperature": 1,
"user": "example"
}

The world’s or the agent’s answer; with stream, server-sent chat.completion.chunk events and [DONE]

Media type*/*

An agent’s answer in OpenAI’s chat.completion shape, answered by the chat completions endpoints when stream is not true

object
choices
required

Exactly one choice, holding the agent’s answer

Array<object>

One answer in a chat completion; there is only ever one

object
finish_reason
required

Always stop

string
index
required

Always 0

integer format: int32
message
required

The agent’s answer

object
content
required

The agent’s whole answer. When the turn raised requests still waiting for approval, it ends with a note listing each one, the run that raised it, and a link to decide it.

string
role
required

Always assistant

string
created
required

When the turn started, in Unix epoch seconds

integer format: int64
embabel

What the turn did; present only when the request set embabel_evidence

object
conversation
required

Id of the chat session the turn ran in

string
refused
required

What the Gatekeeper refused the agent this turn, each as tool (why), e.g. observing, never or egress; empty when nothing was refused

Array<string>
requests
required

Requests for a person’s approval this turn’s run raised, in any status; empty when it raised none

Array<object>

A request for a person’s approval raised during a chat completion turn

object
detail
required

What would happen and why, in the business’s words

string
id
required

Request id, as the approvals surface knows it

string
status
required

Pending, approved, failed, rejected or expired

string
verb
required

Gateway tool the request would call on approval, e.g. odoo_partnerMessagePost

string
run

Id of the agent run the turn went as; every request it raised names it. Absent when the turn ran as no agent.

string
id
required

Chatcmpl- followed by a random UUID, new for every completion

string
model
required

Name of the agent that answered, or world

string
object
required

Always chat.completion

string

No user message to answer, or embabel_observing asked of the world itself

Media type*/*

An OpenAI-shaped error body, answered by the OpenAI-compatible endpoints when they refuse a request

object
error
required

The refusal

object
code
required

Model_not_found when no agent of that name may be talked to now, key_scope when the API key does not reach the agent or the world itself, invalid_request when there is no user message to answer or embabel_observing is asked of the world

string
message
required

Human-readable reason, e.g. why the agent may not be talked to now

string
type
required

Always invalid_request_error

string

No API key or session

Media type*/*

An OpenAI-shaped error body, answered by the OpenAI-compatible endpoints when they refuse a request

object
error
required

The refusal

object
code
required

Model_not_found when no agent of that name may be talked to now, key_scope when the API key does not reach the agent or the world itself, invalid_request when there is no user message to answer or embabel_observing is asked of the world

string
message
required

Human-readable reason, e.g. why the agent may not be talked to now

string
type
required

Always invalid_request_error

string

This key does not reach that model: an agent outside its scope, or the world itself for any agent key, which needs a full key

Media type*/*

An OpenAI-shaped error body, answered by the OpenAI-compatible endpoints when they refuse a request

object
error
required

The refusal

object
code
required

Model_not_found when no agent of that name may be talked to now, key_scope when the API key does not reach the agent or the world itself, invalid_request when there is no user message to answer or embabel_observing is asked of the world

string
message
required

Human-readable reason, e.g. why the agent may not be talked to now

string
type
required

Always invalid_request_error

string

No agent of that name may be talked to now

Media type*/*

An OpenAI-shaped error body, answered by the OpenAI-compatible endpoints when they refuse a request

object
error
required

The refusal

object
code
required

Model_not_found when no agent of that name may be talked to now, key_scope when the API key does not reach the agent or the world itself, invalid_request when there is no user message to answer or embabel_observing is asked of the world

string
message
required

Human-readable reason, e.g. why the agent may not be talked to now

string
type
required

Always invalid_request_error

string