ChannelDocsOpen workspace ↗

API reference

Send inference traffic to https://app.westernrose.uk/v1. The public catalogue lives on westernrose.uk. Send credentials only to the app origin.

POST /chat/completions

Requires a client bearer key and JSON content type. Required fields are a supported model (or a fallback list in models) and a messages array with an optional leading system instruction and 1–31 alternating user and assistant messages, starting and ending with user. Each message needs non-empty text. The combined content limit is 4,096 UTF-8 bytes. The gateway measures the limit in UTF-8 bytes; emoji and accented characters can occupy more than one byte. Omit stream or set it to false.

{"model":"gemini-3.1-flash-lite","messages":[{"role":"user","content":"What measures wind speed?"}]}

Read the answer from choices[0].message.content. Keep the provider response ID and the distinct channel.request UUID. The latter joins to Channel’s settlements. Use the returned model version for analysis when an alias resolves to a dated model.

GET /statement

A client key selects its own statement. A workspace session or management credential may select a client with ?client=First%20app. The response contains month, client, total_micro_gbp and a requests array ordered newest first. Omit month for the current UTC calendar month, or supply ?month=2026-11 for a specific period. Workspace callers can combine client and month. Settled rows belong to the settlement month. An unresolved interrupted request appears in its reservation month until its hold is released. These are current ledger views, so an older period can change after a cross-month settlement. A zero-row response can be valid.

GET /activity

Workspace access required. ?days=1|7|30|90 selects a rolling period; default 30. Rows group settled usage by UTC day, client and model. Wallet values available and held use micro-GBP. A rolling 30-day aggregate can differ from a calendar-month statement.

GET and POST /clients

List client names or create a client with {"name":"First app"}. Creation returns HTTP 201 with client and a one-time key. Names are unique within a workspace, up to 80 characters. A duplicate returns 409. List responses contain names only.

POST and GET /checkout

Workspace access required. Once merchant checkout is active, submit integer credit_pence between 2000 and 100000. The response supplies the order ID and hosted checkout URL. Check GET /checkout?order=… for provider-confirmed state. An unconfigured merchant returns 503.

GET https://westernrose.uk/api/models

Public discovery endpoint. Returns catalogue metadata, including name, model ID, context length and input/output modalities where available. Catalogue pricing and benchmark fields describe listed offerings. Use the routing guide to select a callable Channel ID.

GET /v1/models

Fetch https://app.westernrose.uk/v1/models to populate a model picker. This public, unmetered call returns data, an array of configured routes with an exact model ID, provider in owned_by and input and output modalities. Pass the ID as model in a chat request. To look up one ID, append it to the path. Unknown IDs return 404. A configured credential does not guarantee provider uptime or available provider credit.

System instructions

Put instructions in the first message with role system. Follow it with the conversation, ending with a user question. Include the instruction again on subsequent requests. The 4,096-byte limit includes all message contents. A misplaced or repeated system message returns HTTP 400 before any provider call.

{"model":"gpt-5.4-mini","messages":[{"role":"system","content":"Use British English and answer in one sentence."},{"role":"user","content":"What is a barometer?"}]}

Limit the response length

Set max_completion_tokens or max_tokens to an integer from 1 to 256. For example, add "max_tokens":64 to your chat request for a short answer. Omitting the field sets a limit of 256. Both fields may appear together if their values match. Invalid limits return HTTP 400 before credit is reserved. Every eligible fallback receives the same limit. Model token limits can include reasoning tokens, so the visible answer may be shorter or empty. Usage on your statement comes from the serving provider.

GET /v1/credits

Use a workspace session or workspace bearer credential to read the shared GBP wallet. Client inference keys receive 403. The response contains integer millionths of a pound. For example, {"currency":"GBP","available_micro_gbp":990000,"held_micro_gbp":10000} means £0.99 is available and £0.01 is reserved. Use the available amount to monitor spendable credit. A hold can be released or settled. Use the client statement to inspect a final charge. This lookup does not reserve funds for a future request.

GET /v1/generation?id=…

Use the UUID in channel.request from a successful chat or request from a provider error. The data object reports the billing status, held credit, provider attempts and any recorded token counts and costs. A pending receipt has a null GBP charge. A released hold shows zero. A settled call shows its final charge in micro-GBP with provider usage in nanodollars and the EUR equivalent in micro-EUR. Client keys can read their own requests across months. Workspace credentials can read receipts across their own clients. An unknown or out-of-scope ID returns 404.

Filter connected models

On GET /v1/models, pass output_modalities to match any listed output type, or all to skip that filter. The default is text. Use supported_parameters and endpoints to require every supplied capability or path. Separate values with commas. Combine the filters to find routes that meet all your requirements.

GET /v1/models?output_modalities=text&supported_parameters=max_tokens&endpoints=/v1/chat/completions

An empty data array means no configured route matches. For example, a picker that requires native tool calling can query ?supported_parameters=tools before offering that workflow. Each result describes capabilities Channel exposes through that route.

Compare model prices

List and individual model responses include pricing.prompt and pricing.completion as decimal strings in USD per token. Multiply by one million to compare with a routing price ceiling. Use GET /v1/models?sort=pricing-low-to-high or pricing-high-to-low to sort the filtered results. Channel ranks by the price of one regular input token plus one output token, with model ID breaking ties. For a workload with a different mix, multiply each rate by its own expected token count. Cached input discounts and settlement exchange rates can affect the final charge. Sorting this discovery list does not alter chat routing.

Export a client statement

Use GET /v1/statement?format=csv&month=2026-12 with a client key, or add the client name with a workspace credential. The download has one row per displayed request. Sum micro_gbp and divide by one million to reconcile the GBP amount with the JSON statement. Pending charges have an empty amount, released holds have zero, and the held amount is separate. USD costs use nanodollars and EUR costs use micro-euros. Routing attempts occupy one JSON-encoded cell. An empty period returns column headers only. Spreadsheet-sensitive text receives a leading apostrophe.

Create, list and revoke client keys

Use workspace credentials. Call POST /v1/keys with {"client":"First app"} for an existing client. Save the returned secret key immediately. The separate id identifies this credential for management. GET /v1/keys returns active client key IDs and client names for the workspace. It never returns bearer secrets.

To rotate a key, issue its replacement, update your application and verify a read-only statement request. Then call DELETE /v1/keys/{id} for the old ID. Subsequent authentication with the revoked secret returns 401. Previously accepted requests can finish. Billing history belongs to the client and remains accessible with its replacement key. An unknown or out-of-workspace key ID returns 404.

Troubleshoot a request

401 on a client request
Check the bearer credential in the calling environment. After rotation, use the replacement secret. The management ID returned in the key list cannot authenticate inference.
403 on a workspace endpoint
Key management and the shared wallet require workspace access. Use a client key for chat or for its own statement.
404 during key management
Read the error body. “Unknown client key” on deletion means the ID is absent from the active client keys visible to that workspace. Use GET /v1/keys to confirm the current list. “Unknown endpoint” means the route itself was unavailable at that URL. Check the API origin and path first. If the error persists, record the UTC time, HTTP method, path and the Cloudflare Ray ID from the response headers for support. Exclude bearer credentials.
Ambiguous response to key creation
Check the active key list before repeating a POST. A successful creation returns the secret once. If the response was lost and the new ID can be confidently identified, revoke that ID and issue a fresh credential. Preserve existing application keys when the identity of the new key is unclear.
502 after submitting chat
Use the Channel request ID, when available, to look up its receipt and billing status. A repeated chat submission can create a separate charge.