Security model
Provider API keys are write-only:- the API encrypts each key with AES-256-GCM before inserting it;
- the authenticated encryption context includes organization ID, provider ID, provider type, and credential version;
- PostgreSQL stores ciphertext, a unique nonce, authentication tag, key version, and SHA-256 fingerprint;
- list and create responses expose only the first 12 fingerprint characters;
- the runtime decrypts a key only while activating the selected project preset;
- API keys never appear in model presets, agent snapshots, SSE, audit detail, logs, or traces.
OPENROUTER_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, or
XAI_API_KEY, or AWS_BEARER_TOKEN_BEDROCK in .env. Those keys are entered through the project UI or API
and stored as tenant-scoped ciphertext.
Without OAO_CREDENTIAL_ENCRYPTION_KEY, provider creation, preset publication,
and runtime execution are unavailable. OAO does not fall back to a local fake
model.
Add a provider in the console
- Open Models.
- Select Add provider.
- Choose OpenRouter, OpenAI, Anthropic, xAI (Grok), or Amazon Bedrock.
- Enter a stable project-local key, display name, and API key.
- Select Add provider.
Add a model preset
- Select Add model preset.
- Choose a provider connection.
- In Model, type to search the live catalog available to that connection
and pick a model or OpenRouter saved preset. OAO uses each connection’s
authenticated live catalog. xAI connections use
GET /v1/language-modelsso image-generation, video, voice, and embedding-only IDs are not offered. Amazon Bedrock connections list OAO’s pinned model list, because Bedrock’s model listing API needs AWS request signing rather than an API key. The picker shows the first matches with their model identifier, context window, and reasoning support, and reports how many further matches the search is hiding. - Check the suggested preset key and display name. Both are derived from the
chosen model — for example
claude-sonnet-4-6-v1— with the version suffix moved forward past keys this project already uses. Editing either field stops the suggestion from overwriting it. - For OpenRouter, open Routing and data policy to set routing and data-handling constraints. It stays folded away while it is unset, and the summary next to it always shows the policy that will be stored.
- For OpenAI, review Model settings. New presets default to plain text, standard reasoning mode, medium reasoning effort, medium verbosity, and an automatic reasoning summary. GPT-5.6 presets can select standard or pro mode and reasoning effort from none through max. GPT-6 Astra supports low, medium, high, xhigh, and max; reasoning cannot be disabled.
- For Anthropic, review Claude settings. Thinking can be disabled or set
to adaptive when the model advertises that capability.
maxTokensis the total output ceiling shared by thinking and the visible answer. Effort is limited to the levels advertised by the selected model; new adaptive presets use 20,000 tokens and high effort when supported. - For a supported xAI reasoning model, review Grok settings. The response format is text and reasoning effort defaults to high. Grok 4.6 offers low, medium, high, and xhigh; the picker only offers levels OAO has verified for the selected model. Tools and the system prompt stay on the agent version, where their schemas and instructions are immutable together.
- Select Add model preset.
@preset/<slug>), plus routing controls including fallbacks, zero-data
retention, data collection, upstream allow/deny lists, preference order, sort,
and price caps. OAO sends every OpenRouter model, Claude models and saved
presets included, through OpenRouter’s Responses API, which carries these
routing controls for every model family. The requests are stateless: OAO sends
the full conversation, reasoning items included, on every call and asks
OpenRouter to store nothing. Every tool goes with strict: false, so a tool’s
optional properties stay optional and its free-form objects take any keys; the
Responses API would read a tool without strict as strict. OpenAI, Anthropic, xAI, and Amazon Bedrock are direct provider connections, so
OpenRouter routing controls must be empty.
For direct OpenAI presets, OAO maps the stored controls to the Responses API as
text.format, text.verbosity, reasoning.mode, reasoning.effort, and
reasoning.summary. Reasoning effort is also the Flue default for the agent;
an explicitly configured Harness Operation may still override its own effort.
For direct Anthropic presets, OAO maps the stored controls to the Messages API
as thinking.type, max_tokens, and output_config.effort. Anthropic counts
thinking tokens against max_tokens, so this setting is the hard ceiling for
the combined thinking and visible response. Adaptive thinking and the available
effort values are model capabilities rather than assumptions made by OAO.
Manual thinking.type: "enabled" and budget_tokens are not part of this
preset contract; use adaptive thinking for supported current models or disable
thinking.
For direct xAI presets, OAO stores the exact xai/<catalog-id> returned by the
live language-model catalog and calls https://api.x.ai/v1. Newly available
text-output Grok IDs can be selected without an OAO catalog release. Known Pi
models retain their pinned context/output metadata; a newly discovered ID uses
conservative runtime limits until the pinned Pi catalog adds richer metadata.
For documented xAI reasoning models, OAO stores textFormat and effort, then
maps them to text.format and reasoning.effort on the Responses API. xAI
documents high as the default, with low, medium, and high on Grok 4.5 and xhigh
from Grok 4.6 onward. OAO also offers low, medium, and high on Grok 4.3, even
though Pi’s catalog lists xhigh for Grok 4.3 and 4.5. Reasoning cannot be
disabled on these models. Structured JSON schemas are operation-specific rather
than a fixed model default. xAI server-side tools are not part of this preset
contract; OAO’s versioned agent tools remain available.
Amazon Bedrock
Use Amazon Bedrock when model traffic must stay inside your AWS account and region, or when billing and access control should follow your existing AWS setup.- In the AWS console, open Amazon Bedrock in the region that serves your models and create an Amazon Bedrock API key. The key is bound to that region.
- Make sure model access is enabled in that region for the models you plan to use, and that the key’s IAM principal may invoke them.
- Add a provider of type Amazon Bedrock and paste the key as the API key. No other credential is needed. Access keys, session tokens, and IAM roles are not accepted.
- Set
AWS_REGIONon the runtime worker to the region the key was created in. OAO callshttps://bedrock-runtime.<region>.amazonaws.comand defaults toeu-central-1whenAWS_REGIONis unset. A key used against another region fails with an authorization error from Bedrock.
bedrock/<model-id> and calls the Bedrock Converse
Streaming API. The model ID is the Bedrock model or inference profile ID, for
example bedrock/eu.anthropic.claude-sonnet-5. Pick an inference profile
prefix (eu., us., au., or global.) that matches your data residency
requirements.
Limitations:
- The catalog is the model list pinned in OAO’s Pi dependency. Any other well-formed Bedrock model ID can still be saved in a preset through the HTTP API. The console picker lists catalog models only. Such an ID runs with conservative defaults: text input only, no reasoning, a 128,000-token context window, a 32,768-token output limit, and zero reported cost.
- Presets do not accept generation settings, and OpenRouter routing must be empty. Bedrock presets use the model’s default temperature, thinking, and effort behavior.
- Cost reporting uses the pinned catalog’s prices, which may differ from your AWS pricing.
- Only API keys are supported, not SigV4 credentials.
Inspect, duplicate, or archive a preset
Select a preset in the Model presets table to open it. The dialog shows the key, model, provider connection, price and price history, routing policy or generation settings as JSON, and the agents that currently pin the key.- Duplicate as new preset opens the add dialog prefilled with the same provider, model, policy, settings, and price under the next free key. This is how you “change” a preset: the original stays exactly as published agent versions reviewed it.
- Archive preset removes it from the table and from the agent editor’s preset picker. Agents that pin the key keep running on it, but must move to another preset before they can publish a new version. The key stays reserved.
Set a model preset’s price
A price belongs to one preset, in USD per one million tokens, so each project keeps its own. It has four rates, because providers charge each kind of token differently:
Some models charge more once one call’s input passes a size. Turn on Higher
price for long inputs to add that threshold, counted over the call’s cached
and uncached input, with its own four rates. They then apply to the whole call.
In Add model preset, the Price section is prefilled with the list price
OAO knows for the chosen model. Check it against the provider’s current price,
since OAO’s own list changes only with an OAO release. For OpenRouter models and
saved presets, the prefill is OpenRouter’s current price, so it leaves out any
higher price for long inputs: add that yourself where the model has one. A saved
preset that OpenRouter does not price, and Amazon Bedrock, start empty, so enter
those by hand. For a saved preset, use the price of the model it runs.
The prefill only fills the form. A preset saved without a price uses OAO’s
built-in list when a model call is priced, and that list does not cover OpenRouter
saved presets or Amazon Bedrock, so their runs show no price until you set one.
To change a price later, open the preset and select Change price. A preset
stays immutable, but its price does not have to: the new price is added to the
preset’s history and applies to later model calls, from now or from a later
time you pick, such as the day a promotion ends. A start in the past is
refused. Past runs keep the cost they were given, because each model call
records what it was charged in
debug.modelInvocations[].pricingSnapshot.
OAO prices each model call from the first of these that applies:
- The price set on the run’s preset.
- OAO’s built-in list price for the model.
- Nothing. The call counts as unpriced: its session’s
costProvenanceisunpricedand the console shows no price, not $0. Calls made before a preset had a price stay unpriced.
Set a model preset’s limits
A preset can carry two limits, in tokens:
A limit you leave empty uses the model’s own value from OAO’s model catalog.
OAO does not know which model sits behind an OpenRouter saved preset, or an
OpenRouter model outside its catalog, so for those it uses a context window of
128,000 and an output limit of 4,096 tokens. Such a preset’s calls stop at 4,096
output tokens and compact past 123,904 tokens until you set its limits.
The context window is also how you choose when long conversations compact. A
model that accepts 1,050,000 tokens can still get a context window of 250,000:
its runs then compact past 230,000 tokens instead of sending their whole history
on every call. With an output limit of 128,000, each call may write up to that.
If tool results inside a run leave fewer than 2,000 output tokens in the context
window—or a call stops on
length without producing text or a tool call—OAO
triggers context compaction and retries that turn once. The pre-call output-room
check uses pi’s character-based context-token estimate and runs only when the
conversation has earlier history that compaction can cut; if compaction cannot
free enough room or the retry overflows again, the run fails instead of
completing with an empty reply. A response that hits length after writing text
or requesting tools is kept as returned.
In Add model preset, the Limits section is prefilled with the context
window and output limit the catalog lists for the chosen model; overwrite them
as you need. For an OpenRouter saved preset the catalog knows neither, so the
fields start empty. Use the limits of the model the preset runs.
To change limits later, open the preset and select Change limits (or
Set limits). Like a price, the new limits are added to the preset’s history
without a new agent version or a new preset key. They apply from the preset’s
next run: a run already under way keeps the limits it started with, because a
run resolves its model once. Clear both fields to go back to the model’s own
values. Each model call records the limits it ran with, and where each came
from, in debug.modelInvocations[].safeRequest.modelLimits.
An Anthropic preset also has a Max tokens generation setting. Each of its
calls asks for that setting, or for the output limit when that is smaller, and,
like every call, for no more than the context window leaves. An Anthropic preset
without an output limit keeps its setting as the most a call asks for.
Model timeouts and retries
Each model attempt has a five-minute deadline, including connection setup and the entire response stream. Partial output does not reset the clock. OAO aborts an expired request and discards late results, including late tool calls. This deadline applies to all hosted providers and is fixed by the runtime; there is no per-preset timeout setting. The deadline bounds receiving the provider response. Database admission before that request, processing buffered output, and recording run progress are separate work, so elapsed run time can exceed a single attempt’s deadline. A model-start event records the requested turn; it does not prove that the provider has received the request. OAO checks the durable model-turn budget once per model operation, including new retry and recovery operations. Reading additional response chunks does not repeat that database transaction or consume extra turns. The public progress recorder filters unused text, reasoning, and tool-argument deltas before database access; model outcomes, retries, tool results, and recovery events remain recorded. For agent model turns, timeouts and other transient provider failures use Flue’s durable retry budget: up to three retries after the initial attempt, or four attempts total. Retries back off for approximately 2, 4, and 8 seconds with jitter. Provider SDK retries are disabled so they cannot multiply this budget. Completed tools remain committed and are not executed again by a model retry. Cancellation, authentication failures, and the platform model-turn guard do not trigger these retries. Retry attempts still consume the agent’s model-turn budget, and a run or Harness Operation deadline can stop execution sooner. Four consecutive five-minute timeouts can therefore take about 20 minutes plus retry delays. Reduce reasoning effort or requested output size when a model repeatedly exceeds the deadline; retrying the same large generation can time out again. Internal context-compaction requests share the five-minute deadline but do not use the agent-turn retry loop. The session event inspector shows Model call started and Model retry scheduled entries while an agent turn is pending. These events contain safe timing and retry metadata, never provider credentials or raw error bodies. Timed-out attempts may still incur provider charges; without final provider usage, OAO cannot report their complete token usage or cost.Prompt caching
For OpenRouter models, OAO marks prompt cache breakpoints on every model call, at most three per call:- after the agent’s instructions, which come after its tool definitions, so every session of the agent can read both from the cache;
- after the stable start of a session’s first message, when the session was
created with
promptCache.prefixChars(see Share the prompt cache across sessions); - at the end of the latest message or tool result, so each call of a run reads what the previous call wrote.
prompt_cache_key and as the x-session-id sticky-routing header, so calls
with the same key reach the same provider endpoint and its cache. The key is
the session’s promptCache.key when its creator gave one. Otherwise it is
shared by every session of the same agent version, delegated child sessions
included, each under its own agent version.
Run IDs, the session ID, and the snapshot hash come after a session’s stable
start: OAO opens such a first message with <oao-run type="oao.run.v1"> and
the stable text, and names the delivery IDs in an <oao-run-delivery> element
at its end. A message without a stable start keeps the delivery IDs in the
opening <oao-run> tag.
A first request that writes a prefix reports cacheWriteTokens; a later
request that reads it reports cacheReadTokens. OAO records both separately
for each model call and prices them with the preset’s cache write and cached
input rates. The provider decides what it caches: a prefix shorter than its
minimum (1,024 tokens for OpenAI models) is not cached, an entry expires after
the provider’s cache lifetime, and some providers report no writes because
writing is free. Changing an agent’s instructions or tools, or the stable start
of the message, starts a new cache entry.
Link a model to an agent
Open Agents, create or edit an agent, and choose an available model preset. Publishing validates the preset inside the same tenant-scoped transaction. A project preset is available only when it references a provider connection in that project and platform credential encryption is configured.HTTP API
All routes are scoped to/v1/projects/{projectId}. Reads require
agent:read; writes require project:admin.
Create a provider connection
credentialConfigured: true, a 12-character
credentialFingerprint, and credentialVersion: 1. It never contains
apiKey, ciphertext, nonce, or authentication tag.
List providers
Rotate a provider key
Search the matching catalog
/models catalog
plus saved /presets, exposing saved presets as openrouter/@preset/<slug>
options. For direct OpenAI and Anthropic connections, OAO decrypts the selected
project key server-side and fetches the provider’s live /v1/models catalog.
For xAI, OAO fetches /v1/language-models and exposes text-output entries as
xai/<catalog-id> without relying on a hard-coded Grok list. For Amazon
Bedrock, OAO returns its pinned model list as bedrock/<model-id> and does not
call AWS, so the key is not used. OpenAI uses the
live list for account membership and discovers new GPT-4.1, GPT-5-and-later, and
o3-and-later family IDs without a pinned catalog update. Known
non-Responses models and specialized audio, realtime, transcription, search,
image, embedding, moderation, and deep-research variants are excluded.
Models without verified runtime capabilities and pricing appear with
runtimeSupported: false. The console shows them disabled with an explanation;
the CLI setup only offers supported models. Preset creation rejects unsupported
entries, so naming patterns cannot authorize execution or produce zero-cost usage.
Anthropic responses are intersected with OAO’s pinned runtime models.
Anthropic entries also expose
the model’s adaptive-thinking, thinking-disable, and effort capabilities.
Claude models whose live capabilities do not support effort are not offered,
because every OAO Anthropic preset pins that setting.
Catalog responses contain public metadata only; no provider key is returned.
Create a preset
openai/<catalog-id> model returned by
the catalog, send an empty routing object, and include the immutable model
settings:
anthropic/<catalog-id> model
returned by the catalog, send an empty routing object, and include the
immutable Claude settings:
xai/<catalog-id> returned by the live
language-model catalog. Routing must be empty. Supported reasoning models
accept immutable text-format and effort settings:
price:
Change a preset’s price
validFrom to start now. GET on the same path lists the history,
newest first. Each preset in GET /model-presets carries the price in effect
now as price, or null.
Set a preset’s limits
Create the preset with its first limits by addinglimits:
null uses the model’s
own value. GET on the same path lists the history, newest first, and each
preset in GET /model-presets carries the limits in effect now as limits, or
null when it never had any.
Tenant and lifecycle guarantees
- Provider and preset primary keys include organization and project identity.
- Composite foreign keys prevent cross-project provider references.
- Row-level security is enabled and forced on both relations.
- Provider identity and type are immutable; only encrypted credential material may rotate, and its version must increase.
- Model presets are immutable and cannot be updated or deleted.
- Existing presets created before provider connections were introduced remain visible as unavailable legacy history. Recreate them with a new versioned key linked to a provider connection.
Troubleshooting
Provider creation says encryption is not configured
Set the same canonical base64 32-byteOAO_CREDENTIAL_ENCRYPTION_KEY for the
API and runtime worker, then restart both processes. Do not replace it while
ciphertext encrypted with the old key still exists; key-ring rotation is not
part of this MVP.
A provider key cannot be decrypted
Confirm the API and runtime use the same platform encryption key and that the database row was not copied between tenants or providers. Tenant/provider identity is authenticated, so copied ciphertext intentionally fails.A model is not in the catalog
Search/model-catalog with the intended provider connection. OpenRouter,
OpenAI, Anthropic, xAI, and Amazon Bedrock use separate catalogs and prefixes. If an OpenRouter model
or saved preset is missing, confirm the provider API key can read the OpenRouter
catalog. If a direct OpenAI model is missing, confirm the selected key can list
it through OpenAI’s /v1/models endpoint and belongs to a supported text/reasoning
family. Each catalog request fetches the current account list; OAO does not
cache it or require a library release to discover new family members.
Known OpenAI models retain the runtime metadata from OAO’s pinned model
catalog. GPT-6 Astra is in that catalog with a 272,000-token context window
(where OpenAI’s long-context pricing starts), a 128,000-token output limit,
image input, pricing, and reasoning levels, so it can be selected immediately
when the connected key lists it. Models without verified metadata show unknown
context/output limits and remain disabled until runtime support is added.
Discovery is automatic; enabling a new model still requires verified endpoint,
tool, reasoning, limit, and pricing metadata. This prevents failed runs and
incorrect cost reporting.
If a direct Anthropic model is missing, confirm the selected key can list it
through Anthropic’s /v1/models endpoint. OAO must also have matching native
Anthropic runtime metadata. The model catalog controls whether adaptive
thinking can be enabled or disabled and which effort levels can be saved.
If a Grok model is missing, confirm the selected xAI key can list it through
xAI’s /v1/language-models endpoint and that the entry has text output. Image,
video, voice, and embedding-only models are intentionally excluded from agent
presets.
If a Bedrock model is missing from the list, create the preset through the
HTTP API with "model": "bedrock/<model-id>" and an empty
routing object. The console picker shows catalog models only. If a Bedrock run
fails with an authorization error, confirm the key’s region matches AWS_REGION
and that model access is enabled for that region.
A preset is unavailable
Confirm it has a non-null provider connection, the connection belongs to the same organization, and the runtime has the platform encryption key. Legacy unbound presets are history only.Bundled model catalog
The runtime uses pi-ai 1.6.1. This patch improves retries for temporary provider failures and recognizes additional Google error finish reasons. Its catalog removes retired Groq models and corrects Mistral Medium 3.5 identifiers. OpenRouter routing continues to use the Responses API. Its catalog adds GPT-6.2 Astra and GPT-6.2 Sol (272,000-token context window, 128,000-token output limit) to the OpenAI and Bedrock catalogs, and newer OpenRouter chat models. Several existing OpenRouter entries changed their catalog context window or output limit; a preset without its own limits follows the new catalog values, so set preset limits when a run depends on a specific size. OpenAI-compatible requests without tools omit the empty tools array even with tool history; older proxies that require it needcompat.requiresToolsWithToolHistory. The catalog excludes realtime and
image-only models from chat choices.
Native Anthropic presets use Anthropic message threads. A model call whose
earlier messages and settings match what Anthropic already holds for the
session continues that thread and sends only the new messages; any other call
starts a new thread. Thread state lives in the worker process, so a restarted
or different worker starts a new thread, and an endpoint that rejects threads
gets ordinary requests.
Upstream lists OpenRouter models for Chat Completions or, for Claude, Anthropic
Messages. OAO sends all of them through OpenRouter’s Responses API instead, so
routing controls and prompt cache breakpoints apply to every family; reasoning
is replayed as encrypted reasoning items. Reasoning models from OpenAI and
Anthropic receive their instructions in the developer role; every other
OpenRouter model receives them as system, because other models’ chat
templates may reject developer. OpenRouter billed cost totals use
provider-reported billing; component costs remain catalog estimates.
GPT-6.1 Terra is included, with a 500K context window on the Codex provider.
Model context limits remain provider-specific; configure presets accordingly.
Tool arguments use pi-schema JSON Schema validation and coercion. Validation
messages may differ from earlier releases. Flue 2.3.1 imports TypeBox itself,
so OAO no longer patches it; its persisted format and lease timings are
unchanged.
