This guide covers the public Runtime and contracts 0.4.0 pair. Install both at the same exact version. The quickstart runs one model directly. The integration guide loads a reviewed route set.
| API | Use |
|---|---|
createRouteAIClient, or the Route overload of createAIClient |
Load a Route-set source and capture workflows. Call startRun with application-owned instructions and one Route ID or name. |
createRequestRouteRun |
Run a held Route with its exact catalog and host-supplied connections and credentials. |
createModelRun |
Execute one catalog ID and model settings, with a single attempt and a direct-model receipt. |
createCompatibleClient |
Bind operation controls to an existing run for call sites using Responses or Chat Completions syntax. |
The application supplies provider endpoints, credentials, instructions and access policy. Keep credentials in trusted host code. A request's model field, when supplied, asserts the configured primary model. Change the Route assignment to change the actual selection. Older profile and persona interfaces remain compatibility paths. Use the installed Runtime's MIGRATION.md for the relevant legacy boundary.
import type { DirectModelRun } from "@techis/ai-runtime";
export async function answer(run: DirectModelRun, input: string, signal: AbortSignal) {
return run.responses.create({ input }, {
operationId: "answer.short",
signal,
execution: { timingPolicy: "caller", deadlineMs: 25_000, attemptTimeoutMs: 20_000 }
});
}
Use run.chat.completions.create({ messages: [{ role: "user", content: input }] }, options) for the Chat Completions request style. Both styles use the same execution engine and the adapter selected by the configuration. Legacy generate is a final-result interface. Use the richer interfaces to handle intermediate outcomes and streaming.
| Area | What to handle |
|---|---|
| Output | Responses exposes output and output_text. Chat returns one projected choice. Inspect outcome, canonical items, diagnostics and executionReceipt when the plain-text projection is insufficient. |
| Tool calls | On requires_action, validate and authorize the called function and arguments in your application. Return each result once with its original call ID and the returned continuation. Pass only the new suffix with the continuation. Opaque provider IDs are usable only on compatible pinned execution. |
| Refusal and partial data | Handle refused, incomplete and failed explicitly. A transport or provider failure can reject the call. |
| Streaming | With stream: true, the call returns a lazy single-consumer stream. Iterate its events, then call finalResult(). Calling only finalResult() drains the same invocation. Handle stream failures and cancellation in the host. |
| Time and retries | Use signal and caller-owned deadlines. Eligible failures can try ordered backups while policy and budget allow and before any provider-derived output reaches the caller. A backup must satisfy any required features specified in featurePolicy. |
| Errors and usage | Catch AISubsystemError and inspect its code and applicable receipt. Route execution uses executionReceipt and direct model failures expose directModelExecutionReceipt when there is a receipt. Keep receipt and operation IDs for correlation. Unknown usage or cost stays unknown. |
Calls can include text, supported image inputs, functions, output formats, reasoning, and provider-hosted search where mapped. Inspect the chosen adapter and model constraints. Provider options apply in a provider-specific namespace and cannot override Runtime-owned fields such as credentials, endpoint, model and continuation. Native responses and continuation data may contain sensitive information. Apply your application's data policy before logging them.
| Provider | Runtime adapter route | Outbound protocol and examples of limits |
|---|---|---|
| OpenAI | openai-chat-completions |
Chat Completions API for both client styles, including streamed text and client function calls. |
| OpenAI | openai-responses |
Responses API for both client styles. Native web search and schema support depend on model and request. |
| Anthropic | anthropic-messages |
Messages API. Tool, thinking and structured-output settings depend on the model and supported protocol subset. |
| Google Gemini | gemini-generate-content |
Interactions v1. The stable adapter ID retains its earlier name. Review function and reasoning controls for v1. |
| Z.AI | zai-chat-completions |
Native Chat. Schema handling uses JSON-object mode and local validation. |
| Moonshot | moonshot-chat-completions |
Native Chat. This adapter omits hosted search. An application can supply its own authorized search function. |
The preview covers the documented final and streaming compatibility interfaces. Media generation, audio/video, embeddings, reranking and realtime are outside this release. For field-level mappings, the installed @techis/ai-runtime package includes API.md, OPENAI-RESPONSES.md, OPENAI-CHAT.md, ANTHROPIC-MESSAGES.md, GEMINI-INTERACTIONS.md, ZAI-CHAT.md and MOONSHOT-CHAT.md. Use ADAPTER-AUTHORING.md and ADAPTER-CONFORMANCE.md to build, register and test custom adapters.