OpenProgram Docs

OpenAI-compatible API

Your tool any OpenAI client Worker :18100/v1 Agent turn tools, memory, model API key: the Web token model: an Agent's id stored as a conversation The answer comes back as chat.completion, or as chunks ending in [DONE].
  1. Your toolany OpenAI client, the Web token as its API key
  2. Workerhttp://127.0.0.1:18100/v1, model: an Agent's id
  3. Agent turnstored as a conversation; answered whole or streamed

Connect a tool

SettingValue
Base URLhttp://127.0.0.1:18100/v1, or localhost; the Worker's own port if you changed it
API keyThe Web token in ~/.openprogram/web/token (~/.openprogram-<profile>/web/token for a profile). A new one is made each time the Worker starts, so read the file at call time.
ModelAn Agent's id, as GET /v1/models lists them, the default Agent first
curl http://127.0.0.1:18100/v1/chat/completions \
  -H "Authorization: Bearer $(cat ~/.openprogram/web/token)" \
  -H "Content-Type: application/json" \
  -d '{"model": "main", "messages": [{"role": "user", "content": "Summarise README.md"}]}'
from pathlib import Path
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:18100/v1",
                api_key=(Path.home() / ".openprogram/web/token").read_text())
for chunk in client.chat.completions.create(
        model="main", stream=True,
        messages=[{"role": "user", "content": "What changed today?"}]):
    print(chunk.choices[0].delta.content or "", end="")

What a request does

PartBehaviour
TurnOne turn of the Agent, as if typed in the App: its model, tools, memory and permission mode. It shows in the App while it runs and stays there as a conversation.
MessagesThe last message must be the user's; it is the turn's message. Earlier messages, including system, go with it as the calling tool's context. Content is text, or a list of text parts.
ConversationEach request starts a new one. To add a turn to an earlier one instead, send its id in conversation_id; then only the last message is sent. Every answer names its conversation in conversation_id and the X-OpenProgram-Conversation-Id header.
Streaming"stream": true sends the reply text as chat.completion.chunk events, then a chunk with finish_reason, then data: [DONE]. stream_options.include_usage adds a usage chunk.
ApprovalsNo one is there to answer, so a step that would ask for approval or ask you a question is refused at once, as with openprogram --print.
StoppingClosing a streamed request stops its turn.
Ignoredtemperature, max_tokens, tools and other sampling or function-calling fields: the Agent's own settings and tools apply. n other than 1 is refused.

Errors

Every refusal has OpenAI's body, {"error": {"message", "type", "param", "code"}}.

StatusWhen
401 invalid_api_keyNo token, or a token from an earlier Worker: read the token file again
400A malformed request; param names the field
404 model_not_foundNo Agent has that id
404 unknown_urlA /v1 endpoint this server does not serve, such as /v1/responses
409 conversation_busyThe named conversation is running a turn; send again when it ends
429, 502The Agent's model failed; code carries the reason. In a stream the error is the last event before [DONE].

Scope

  • The token is the owner's: whoever holds it acts as you. Keep the Worker on loopback unless you set up access from other machines.
  • Callers outside a browser only. A web page on another origin is refused.
  • Chat Completions only; no /v1/responses, embeddings or images.

Editor (ACP)

Last updated · 2026-11-25