Completions ​
Use completionModel(...) for direct completions, agents, extractors, structured output, and model-driven pipeline stages.
import { Agent } from '@anvia/core'
import { OpenAIClient } from '@anvia/openai'
const openai = new OpenAIClient({
apiKey: process.env.OPENAI_API_KEY!,
})
const model = openai.completionModel({
modelId: 'gpt-5.6-sol',
api: "responses"
})
export const supportAgent = new Agent({
id: 'support',
model,
instructions: 'Answer support questions clearly and concisely.',
})Use gpt-5.6-sol for complex professional work, coding, and agentic workflows. For cost-sensitive, high-volume completion workloads, create the same adapter with modelId: 'gpt-5.6-luna'.
The returned model implements Anvia's streaming completion contract, so it can back agent.generate(), agent.stream(), and the direct completion helpers.
Direct request ​
Call the model directly when one request is enough and the application owns the surrounding flow:
import { generateCompletion } from '@anvia/core'
const result = await generateCompletion({
prompt: 'Checkout requests timed out for 12 minutes.',
model,
instructions: 'Write one concise internal incident summary.',
maxTokens: 160
})
console.log(result.text)Use an agent when the run needs tools, memory, dynamic context, lifecycle policy, or multiple turns. Use parsed completion when one request must return schema-validated data.
Reasoning effort ​
OpenAI completion models advertise a typed reasoningEffort control. Inspect model.controls for the allowed values; gpt-5.6-* currently accepts none, low, medium, high, xhigh, and max.
const result = await generateCompletion({
prompt: 'Write one concise internal incident summary.',
model,
controls: { reasoningEffort: 'medium' },
})An Agent can set the same default and override it per run:
const agent = new Agent({
id: 'support',
model,
controls: { reasoningEffort: 'medium' },
})
await agent.generate({
prompt: 'Solve this.',
controls: { reasoningEffort: 'high' },
})Omitting reasoningEffort leaves the Agent default, or the provider default when none is configured. Invalid values are rejected before the OpenAI call. Use providerOptions only for OpenAI fields that are not represented as typed controls.
Supported contract features ​
The Responses adapter (api: 'responses') declares streaming, tools, tool choice, image input, file-document input, output schemas, reasoning content, and provider-executed tools. Chat is the default when api is omitted and declares streaming, tools, tool choice, image input, output schemas, and reasoning, but not file documents or provider-executed tools.
Support at the adapter level does not guarantee that every OpenAI model ID accepts every feature. Test the exact model and request shape used by the application, especially required tool calls, structured output, documents, and streamed tool arguments.
Keep provider options local ​
Provider-specific request values belong at a narrow model-call boundary. Avoid spreading OpenAI-specific fields through agents, domain services, or UI types. That keeps the workflow testable with a fake CompletionModel and makes future provider changes explicit.
For adapter selection and capability differences, continue to Responses and Chat.