Skip to main content
Use openaiDecisions() from @agentium/core to evaluate a fixed set of questions. Agentium 4.1 adds OpenAIDecisionsProvider, DecisionQuestion, DecisionAnswer, and result.decisions. The adapter calls POST /v1/decisions. OpenAI now documents Decisions as generally available with gpt-6-luna as its supported model. The examples below target Agentium 4.11.0, including native JSON evidence, preserved message roles, hosted images, and prompt caching. See the official Decisions guide.

Classify a support ticket

Install Agentium and the optional OpenAI SDK. This adapter requires openai 7.30.0 or later.
Save this as decisions.ts:
Run npx tsx decisions.ts. The program prints one typed answer per question. Calls require an OpenAI API key and account access and incur provider usage. The exact answers vary with the input and model.

Questions and results

name is optional. Supplied names must be unique; unnamed answers use null. Answers retain request order. Agentium validates their types, names, choice values, and score levels against the questions. result.decisions contains the validated array. result.text contains that array as JSON. Refusals are answer data, not invented negative answers. An all-refused provider response uses finishReason: "content_filter"; a successfully completed Agent run can still contain refusals. Use question instructions to define the task. Agentium 4.11.0 preserves system, developer, user, and assistant roles and paired function-call history. Earlier adapters converted roles to text labels. Recheck classification examples when upgrading; see the 4.11 upgrade guide.

Configuration and overrides

A run’s questions array replaces constructor defaults. An empty array is an error. Existing Jev question maps remain supported by jev(); the two providers reject each other’s question formats. The adapter forwards AbortSignal to the SDK. Agent runs use Agentium’s retry policy for rate limits and transient server failures. Direct provider.generate() calls do not retry. Credential overrides are not retained for later requests.

Images

Use Agentium’s multimodal input with { type: "image", data, mimeType }. Supply raw base64 with a supported image MIME type or a complete inline data URL. The adapter accepts inline data and hosted HTTP(S) image URLs, with at most 128 images across shared evidence, tool outputs, and question instructions. Hosted URLs are forwarded to OpenAI without downloading them. File IDs, audio, and file parts are rejected. See the request contract.

Streaming and costs

agent.stream() performs one complete request. It emits one text chunk containing the answer array, followed by a finish chunk with decisions and usage. It does not deliver incremental model output. The run.complete event also contains output.decisions. The accounting record identifies the Decisions API separately from Chat Completions and Responses. A matching catalog rule must cover its billed input units and any regional or context adjustments. An incomplete rule match produces total: null. See cost accounting and OpenAI pricing and availability.

Integration limits

This provider rejects tools, structuredOutput, responseFormat, sampling controls, reasoning settings, and chat-specific provider options. Select an action with a choice question, then let application code execute it. Use a chat provider when you need generated tool arguments or arbitrary structured output. Agentium bypasses semantic caching for this provider because the semantic cache key does not include the question set. Memory features that add tools or make auxiliary chat calls require a compatible chat model. Use this provider for a dedicated decision agent or direct model calls. Tests exercise the installed OpenAI SDK against a local HTTP fixture, including cancellation, credentials, refusals, and streaming. These tests do not establish live account availability or model accuracy. Evaluate representative examples before selecting application thresholds.

Native evidence and prompt caching

Existing Agent.run() and stream() calls keep their question and answer shapes. The updated adapter preserves system, developer, user, and assistant roles and paired function-call history. Questions accept string instructions or text/image parts, up to 400 questions per request. Shared evidence, tool outputs, and question instructions together may contain at most 128 images. Hosted HTTP(S) images are forwarded to OpenAI; Agentium does not download them. Construct OpenAIDecisionsProvider for native evaluate() calls with JSON evidence and custom-tool history. The registry-backed openaiDecisions() factory keeps its generic ModelProvider type for existing Agent integrations:
JSON input is limited to objects or arrays of objects, with finite JSON values inside, 32 container levels, 10,000 values, and 256 KiB of compact UTF-8. Keys such as role and image_url inside JSON remain data. Tool calls and outputs are ordered evidence linked by call_id; they do not execute tools. Audio, files, item references, circular JSON, and unmatched outputs fail before a request is sent. Set constructor defaults or per-call promptCacheKey and promptCacheOptions: { mode: "explicit" }. Mark shared text/image boundaries with prompt_cache_breakpoint: { mode: "explicit" }. With explicit mode and no markers, the request does not use prompt caching. Question instructions are outside the reusable prefix and cannot contain breakpoints. The default implicit prefix requires at least 1,024 tokens. See the provider caching contract. The adapter uses openai@7.30.0 through its documented generic request method, without a second HTTP client. It preserves credential overrides, cancellation, and zero SDK retries. Invalid answers and cancellation after a billed response retain available usage. Direct evaluate() returns usage but does not create an Agent ledger attempt. The updated catalog prices ordinary input, cache reads, and cache writes separately. Output is free under the verified Decisions contract. Missing counters or unsupported billing dimensions remain incomplete; saved assessments are not repriced automatically.

Next steps