Bring your own AI
The console's AI features run on your model provider and key: Anthropic (the
Messages API), OpenAI (Chat Completions), Gemini (generateContent), any
OpenAI-compatible endpoint (Ollama, vLLM, a gateway's AI route), or the built-in
mock provider for demos and tests. Nothing calls a model until a key is set; with one,
an assist bar sits in the console's top bar (Ctrl+K / Cmd+K) with suggestions
for the view you are on, answers stream into a drawer, and apply cards do what
the answer proposes (open a view, copy a command, send a request) only when you
click them. This page is the engine and the shell; the mock-building tasks (describe an API,
generate examples, edit a spec) are on Build mocks with AI; the MCP
tasks come with the inspector.
Set it up
From the environment at startup, or under Management, AI at any time (the
instance settings assist.*;
a value saved in the console wins over the variable):
RUSTYBIN_ASSIST_PROVIDER=anthropic RUSTYBIN_ASSIST_ANTHROPIC_KEY=sk-ant-... rustybin
RUSTYBIN_ASSIST_PROVIDER=openai RUSTYBIN_ASSIST_OPENAI_KEY=sk-... rustybin
RUSTYBIN_ASSIST_PROVIDER=gemini RUSTYBIN_ASSIST_GEMINI_KEY=AIza... rustybin
# any OpenAI-compatible endpoint; a local one also needs the outbound loopback switch
RUSTYBIN_ASSIST_PROVIDER=compatible RUSTYBIN_ASSIST_BASE_URL=http://localhost:11434/v1 \
RUSTYBIN_ASSIST_MODEL=llama3.2 RUSTYBIN_EGRESS_ALLOW_LOOPBACK=true rustybin
# the built-in provider: deterministic answers, no key, no network
RUSTYBIN_ASSIST_PROVIDER=mock rustybin
| Setting | Variable | Meaning |
|---|---|---|
assist.provider | RUSTYBIN_ASSIST_PROVIDER | anthropic, openai, gemini, compatible or mock; empty: off |
assist.model | RUSTYBIN_ASSIST_MODEL | The model for specs, edits and answers; empty: the provider's default from the curated table |
assist.fast_model | RUSTYBIN_ASSIST_FAST_MODEL | The model for cheap tasks (suggestions, explanations); empty: the provider's fast default |
assist.base_url | RUSTYBIN_ASSIST_BASE_URL | The compatible endpoint's base, without /chat/completions |
assist.anthropic_key, assist.openai_key, assist.gemini_key, assist.compatible_key | RUSTYBIN_ASSIST_*_KEY | One secret per provider, sealed at rest, returned as {set, hint} only |
Management, AI shows the state (on, or why not), the curated models of every
provider with their tier (fast or capable) and list price where known, with
Use and Fast buttons, the key fields (masked, Replace), the compatible base
URL, Test the key (one short call: latency, model, the answer), the usage since
start and the privacy note. Use the built-in mock LLM switches to the mock provider
for a demo without a key.
GET {{base_url}}/_rustybin/assist
HTTP 200
[Asserts]
jsonpath "$.enabled" == true
jsonpath "$.provider" == "mock"
jsonpath "$.model" == "rustybin-mock"
jsonpath "$.providers" count == 5
jsonpath "$.providers[0].id" == "anthropic"
jsonpath "$.providers[0].key.set" == false
jsonpath "$.providers[1].models[0].id" == "gpt-5"
jsonpath "$.providers[1].models[0].price_per_million.input" == 1.25
jsonpath "$.tasks[*].name" contains "free_answer"
jsonpath "$.tasks[*].name" contains "explain"
jsonpath "$.tasks[*].name" contains "suggest"
jsonpath "$.suggestions.mocks" count == 4
jsonpath "$.caps.calls_per_minute" == 20
jsonpath "$.privacy" contains "never leave"
PATCH {{base_url}}/_rustybin/settings
X-Rustybin-Admin-Token: {{admin_token}}
Content-Type: application/json
{ "values": { "assist.provider": "openai", "assist.model": "gpt-5-mini" }, "secrets": { "assist.openai_key": "sk-example-not-a-real-key" } }
HTTP 200
[Asserts]
jsonpath "$.settings[?(@.key == 'assist.openai_key')].value.set" == true
jsonpath "$.settings[?(@.key == 'assist.openai_key')].value.hint" == "-key"
body not contains "sk-example"
GET {{base_url}}/_rustybin/assist
HTTP 200
[Asserts]
jsonpath "$.enabled" == true
jsonpath "$.provider" == "openai"
jsonpath "$.model" == "gpt-5-mini"
jsonpath "$.fast_model" == "gpt-5-mini"
jsonpath "$.key_set" == true
# The provider's host is allowed under the assist purpose once a key is set.
GET {{base_url}}/_rustybin/egress
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
[Asserts]
jsonpath "$.purposes[?(@.purpose == 'assist')].allow[0]" contains "api.openai.com"
# Back to the mock for the next examples.
DELETE {{base_url}}/_rustybin/settings/assist.provider
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
DELETE {{base_url}}/_rustybin/settings/assist.model
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
DELETE {{base_url}}/_rustybin/settings/assist.openai_key
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
The provider's host is allowed under the outbound policy's
assist purpose the moment its key is set (api.anthropic.com, api.openai.com,
generativelanguage.googleapis.com, the compatible base URL's host); calls carry a
60 second timeout, a 2 MiB response cap, pinned addresses and no redirects. The rule
names only the provider's host, so it holds in public mode too. A rustybin.yaml
pulled from source control cannot change assist.provider or
assist.base_url (a different value is reported and kept), so a repository never
sends the stored key to another host.
Models and jobs
Every task is a job that runs on a model: the capable jobs (describe an API,
generate examples, edit with AI, free answers) on assist.model, the fast ones
(explain, suggestions, request examples, tool arguments, sampling, server.json,
the portal summary) on assist.fast_model, unless its own setting
assist.job.<task> names another model. GET /_rustybin/assist/models answers the
configured provider's models, each with its tier, context window, output limit,
list price, whether it reasons before answering, whether it is curated and whether
the provider listed it, and the jobs it runs; plus every job with its model and
where the model comes from (setting or default).
POST /_rustybin/assist/models (admin) asks the provider for its list with the
stored key (OpenAI and compatible endpoints GET /models, Anthropic GET /v1/models, Gemini GET /v1beta/models, generateContent models only; the mock
lists its own model), through the outbound policy, and keeps at most 500 entries.
The list is served for the provider, base URL and key it was loaded with, for 12
hours; a change of key or URL hides it until it is loaded again. A load within five
seconds of the last one answers that one (no second call). A provider that refuses
answers 502 (provider_error); no provider or no key answers 503
(assist_disabled).
A job setting that names a model the provider does not offer (a model of another
provider after a switch, or an id that is neither curated nor in the loaded list) is
ignored: the job runs on its tier default and the job's ignored field names
the model, so a Claude model is never sent to OpenAI. A compatible endpoint has no
curated table, so before its list is loaded it takes any id. assist.provider
accepts the aliases claude, google and openai-compatible and stores the
provider's name.
GET {{base_url}}/_rustybin/assist/models
HTTP 200
[Asserts]
jsonpath "$.provider" == "mock"
jsonpath "$.loaded" == null
jsonpath "$.models[0].id" == "rustybin-mock"
jsonpath "$.models[0].curated" == true
jsonpath "$.models[0].default_for" count == 2
jsonpath "$.jobs[*].task" contains "explain"
jsonpath "$.jobs[?(@.task == 'explain')].tier" == "fast"
jsonpath "$.jobs[?(@.task == 'explain')].source" == "default"
# Load the provider's list with the stored key (admin): the mock lists its own model.
POST {{base_url}}/_rustybin/assist/models
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
[Asserts]
jsonpath "$.loaded.kept" == 1
jsonpath "$.models[0].listed" == true
# One job on its own model; an alias of a provider name is stored as the name.
PATCH {{base_url}}/_rustybin/settings
X-Rustybin-Admin-Token: {{admin_token}}
Content-Type: application/json
{ "values": { "assist.job.explain": "mock-fast-9" } }
HTTP 200
GET {{base_url}}/_rustybin/assist/models
HTTP 200
[Asserts]
jsonpath "$.jobs[?(@.task == 'explain')].model" == "mock-fast-9"
jsonpath "$.jobs[?(@.task == 'explain')].source" == "setting"
DELETE {{base_url}}/_rustybin/settings/assist.job.explain
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
In the console, Management, AI, Models and jobs has the load button, the provider's models with Use and Fast, the jobs table (an ignored choice is flagged) and a field per job that offers the provider's models to pick from (the curated ones, and every model of the loaded list once it is loaded) and still takes any id. To refresh the list, load it again: a loaded list lasts 12 hours, and a new key or base URL hides it until it is loaded with them.
The console
- The assist bar (top bar,
Ctrl+K/Cmd+K): "Ask Rustybin". Focusing it shows three or four suggestions for the current view (a static list; with a real provider thesuggesttask refines them, cached for an hour per view and model). Submitting streams the answer into the drawer on the right: markdown with copyable code blocks, the provider and model, the tokens used and the estimated cost (where the list price is known), and What was sent, the exact prompts that went out. The drawer resizes, keeps the last 20 exchanges for the browser tab, and reopens where the tab left it. - Apply cards. An answer may end with actions:
open_view(a console view),copy(text to the clipboard),run_request(a request to this instance's own data plane, whose status and body appear under the card),create_mock(the wizard's Describe tab with the description filled in),edit_specandgenerate_examples(the dialogs of a mock). Nothing is applied without a click. - Sparkle buttons where the work is: Explain on a captured request in Live traffic, Describe it, Generate with AI and Edit with AI on mocks; generate arguments on MCP tools and write a scenario on the harness builder come with their steps. Without a key they say so and open Management, AI.
- The overview gets an Ask Rustybin card with three suggestions, and the navigation marks the views with AI actions with a sparkle once assist is on.
- Without a key the bar reads "Add an AI key to describe what you want" and opens Management, AI. No feature is hidden, none is a dead end.
Tasks
A task is the only way to call a model: a name, a system prompt, a user prompt rendered
from validated inputs, an optional output JSON schema and a deterministic mock answer.
Structured tasks use the provider's native JSON mode (tool use on Anthropic,
response_format: json_schema on OpenAI, responseSchema on Gemini, json_object plus
the schema in the prompt on a compatible endpoint) and are validated with the same JSON
Schema validator the mocks use; an invalid answer goes back to the model with the
errors, at most twice.
| Task | Inputs | Answer | Tier |
|---|---|---|---|
free_answer | question, view, context (what the view shows, at most 32 KiB) | Markdown, with action blocks | capable |
explain | kind (request, tool, operation, text), subject | {summary, details, gateway_notes, next_steps} | fast |
suggest | view, context | {suggestions: [{label, prompt}]} (three or four), cached per view and model for an hour | fast |
spec_from_description | description, openapi_version, style | An OpenAPI document, parsed and checked (mocks) | capable |
examples_for_operations | spec, operations, per_response, persona | {examples: {op: {status: [...]}}}, each validated against its schema | capable |
edit_spec | spec, instruction | The whole document, checked, with a bounded structural diff | capable |
request_examples | spec, operation, count | {requests: [{path, query, headers, body}]}, validated | fast |
tool_arguments | tool (name, description, inputSchema), hint | {arguments}, validated against the tool's inputSchema (inspector) | fast |
sampling | messages (at most 50), system_prompt | The reply to a server's sampling/createMessage | fast |
server_json | draft (the generated entry), tools, hint | {server, notes}, valid against the registry schema (registry) | fast |
summarise_for_portal | title, description, operations, hint | {title, summary, tags}, checked like a publish (portal) | fast |
POST /_rustybin/assist/run runs one. Streamed (stream: true, or Accept: text/event-stream), the events are sent (what goes to the provider, never the
key), delta ({text}), json (the validated structured answer), action, usage
(input_tokens, output_tokens, estimated_cost_usd, cached), error and done.
Otherwise one JSON document comes back:
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
{
"task": "free_answer",
"inputs": { "question": "How do I see which headers my gateway added?", "view": "traffic", "context": { "captured": 3 } },
"stream": false
}
HTTP 200
[Asserts]
jsonpath "$.task" == "free_answer"
jsonpath "$.text" contains "Mock assistant"
jsonpath "$.text" not contains "```action"
jsonpath "$.actions" count == 2
jsonpath "$.actions[0].action" == "open_view"
jsonpath "$.actions[0].payload.view" == "traffic"
jsonpath "$.actions[1].action" == "run_request"
jsonpath "$.usage.provider" == "mock"
jsonpath "$.usage.estimated_cost_usd" == 0
jsonpath "$.sent.model" == "rustybin-mock"
jsonpath "$.sent.user" contains "How do I see which headers"
jsonpath "$.sent.user" contains "\"captured\": 3"
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
Accept: text/event-stream
{ "task": "free_answer", "inputs": { "question": "What is a request bin?", "view": "bins" } }
HTTP 200
[Asserts]
header "Content-Type" startsWith "text/event-stream"
body startsWith "event: sent"
body contains "event: delta"
body contains "event: action"
body contains "event: usage"
body contains "event: done"
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
{
"task": "explain",
"inputs": {
"kind": "request",
"subject": { "method": "GET", "path": "/anything/orders", "headers": { "X-Forwarded-For": "203.0.113.9", "X-Request-Id": "c1d2" } }
},
"stream": false
}
HTTP 200
[Asserts]
jsonpath "$.json.summary" contains "GET request to /anything/orders"
jsonpath "$.json.details" count >= 1
jsonpath "$.json.gateway_notes" count == 2
jsonpath "$.text" == null
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
{ "task": "suggest", "inputs": { "view": "mocks" }, "stream": false }
HTTP 200
[Asserts]
jsonpath "$.json.suggestions" count == 4
jsonpath "$.json.suggestions[0].label" exists
jsonpath "$.json.suggestions[0].prompt" exists
jsonpath "$.usage.cached" == false
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
{ "task": "suggest", "inputs": { "view": "mocks" }, "stream": false }
HTTP 200
[Asserts]
jsonpath "$.usage.cached" == true
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
{ "task": "describe_everything", "inputs": {} }
HTTP 404
[Asserts]
jsonpath "$.reason" == "unknown_task"
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
{ "task": "suggest", "inputs": { "view": "nowhere" } }
HTTP 400
[Asserts]
jsonpath "$.reason" == "invalid_inputs"
With control-plane auth, the tasks need assist.use (the tester role, the console
scope); testing the key and loading the models need settings.write, the usage
settings.read, and AI-built mocks assist.jobs.
Privacy and costs
- Keys never leave the instance: not in the API (
{set, hint}), not in exports, not in captures, not in prompts. The request builder scans every prompt for the value of any stored secret and the admin token and refuses the call, naming the setting, never the value:
PATCH {{base_url}}/_rustybin/settings
X-Rustybin-Admin-Token: {{admin_token}}
Content-Type: application/json
{ "secrets": { "leads.webhook_token": "hook-secret-k3Qx" } }
HTTP 200
POST {{base_url}}/_rustybin/assist/run
Content-Type: application/json
{ "task": "free_answer", "inputs": { "question": "Is hook-secret-k3Qx a strong token?" }, "stream": false }
HTTP 422
[Asserts]
jsonpath "$.reason" == "secret_in_inputs"
jsonpath "$.error" contains "leads.webhook_token"
DELETE {{base_url}}/_rustybin/settings/leads.webhook_token
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
- What was sent in the drawer is the record the server made: the provider, the model, the system prompt, the user prompt and the schema.
- Caps:
RUSTYBIN_ASSIST_MAX_CALLS_PER_MINUTE(20) per caller (the control principal, plus the client address on an open control plane; a token caller of the management MCP is its credential, whatever itsX-Rustybin-Session) answers429withRetry-After;RUSTYBIN_ASSIST_MAX_OUTPUT_TOKENS(8192) bounds every answer. A reasoning model (OpenAI's GPT-5 and o-series) spends part of that budget thinking: Rustybin asks it for low reasoning effort, and an answer the budget cuts off is reported as "the model hit its output token limit" rather than used. - Usage:
GET /_rustybin/assist/usage(admin) counts calls, errors, tokens and the estimated cost since start, in total, per provider and model (at most 64 series) and per task; the metricsrustybin_assist_calls_total{provider,model,task,outcome}andrustybin_assist_tokens_total{provider,model,direction}count the same (the model label is bounded to 32 values, thenother). Costs use the curated table's list prices; a model without one shows no number.
POST {{base_url}}/_rustybin/assist/test
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
[Asserts]
jsonpath "$.ok" == true
jsonpath "$.provider" == "mock"
jsonpath "$.answer" == "OK"
jsonpath "$.latency_ms" isInteger
GET {{base_url}}/_rustybin/assist/usage
X-Rustybin-Admin-Token: {{admin_token}}
HTTP 200
[Asserts]
jsonpath "$.total.calls" >= 5
jsonpath "$.by_model[0].provider" == "mock"
jsonpath "$.by_task[*].task" contains "explain"
jsonpath "$.caps.max_output_tokens" == 8192
GET {{base_url}}/_rustybin/metrics
HTTP 200
[Asserts]
body contains "rustybin_assist_calls_total{provider=\"mock\",model=\"rustybin-mock\",task=\"explain\",outcome=\"ok\"}"
body contains "rustybin_assist_tokens_total{provider=\"mock\",model=\"rustybin-mock\",direction=\"output\"}"
The mock provider
RUSTYBIN_ASSIST_PROVIDER=mock (or Use the built-in mock LLM) answers every task
deterministically from the instance itself: the free answer names the view and the
question and proposes two actions, explain summarises the subject and flags headers
that look gateway-added, suggest returns the static list. It is how the console
check, the documentation examples and the tests exercise every AI path without a key
or the network, and how a demo shows the shell before a key is at hand.
On every surface
The same job from the API, the console, the command line, an agent and the configuration document.
| Surface | Where |
|---|---|
| API | GET /_rustybin/assist, POST /_rustybin/assist/run, POST /_rustybin/assist/test, GET /_rustybin/assist/usage, GET and POST /_rustybin/assist/models |
| Console | The assist bar (Ctrl+K), the sparkles in every view, Management, AI (the provider, keys, models and jobs) |
| CLI | rustybin ai status | models [--load] | jobs | use | usage | test | run, rustybin settings set assist.provider ..., rustybin settings set-secret assist.anthropic_key (reference) |
| Management MCP | assist_status, list_assist_models, load_assist_models (confirmed), assist_usage, test_assist, run_assist_task (the read tasks); choosing a model is update_settings; keys are never tool inputs (agent page) |
rustybin.yaml | settings: assist.provider, assist.model, assist.fast_model, assist.base_url, assist.job.<task>; the keys under secrets: as ${VAR} or secret:stored references, never values |
| Environment | RUSTYBIN_ASSIST_PROVIDER, _MODEL, _FAST_MODEL, _BASE_URL, _ANTHROPIC_KEY, _OPENAI_KEY, _GEMINI_KEY, _COMPATIBLE_KEY, _MAX_CALLS_PER_MINUTE, _MAX_OUTPUT_TOKENS, _VISITORS (configuration) |