Overview
The OpenAI-compatible provider connects core-ai to third-party endpoints that implement the Chat Completions API. It accepts known nonstandard response fields used by gateways and inference servers. It provides models through the Chat Completions API with compatibility extensions enabled. Use@core-ai/openai for OpenAI’s
Responses API, strict Chat Completions, embeddings, and image generation.
Installation
createOpenAICompat()
Options
string
API key sent to the compatible endpoint.
string
Base URL for the compatible Chat Completions endpoint.
OpenAI
A configured OpenAI SDK client.
boolean
Whether to extract nonstandard
reasoning_content and reasoning response
fields. Defaults to true.'tool' | 'json-schema' | 'json-object'
How
generateObject() and streamObject() request structured output.
Defaults to tool for broad endpoint compatibility. Set this to
json-schema when the endpoint supports strict JSON Schema response
formats. Use json-object for endpoints that support JSON Mode without JSON
Schema.'max_tokens' | 'max_completion_tokens'
Request parameter used for
maxTokens across this provider. When unset,
known OpenAI models use their registered capability and unknown models use
max_tokens.Returns
OpenAICompatProvider with a single chatModel() method.
Generate text
Model capabilities
Each model exposesmodel.capabilities for unified reasoning, sampling, and
tool-choice constraints:
structuredOutputMode, maxTokensParameter, and reasoning. The fallback
includes 'image' and 'file' in modalities.input, so multimodal requests
are forwarded to the endpoint rather than rejected locally.
The reasoning provider option controls extraction of nonstandard response
fields; it does not change model.capabilities.
Compatibility behavior
The provider follows the standard Chat Completions request and response shapes, then recognizes these additional reasoning output fields:reasoning_content, used by DeepSeek, Qwen, GLM, vLLM, and SGLangreasoning, used by OpenRouter
result.reasoning.
Streaming values emit reasoning-start, reasoning-delta, and
reasoning-end events.
Structured output uses a forced function tool by default because support for
response_format.json_schema varies between compatible endpoints. Endpoints
that implement strict JSON Schema output can opt in:
json-object. The provider adds the
schema to the system message and sends
response_format: { type: 'json_object' }:
createOpenAI().chat.chatModel() when you do not want compatibility extensions.
Provider-specific options
Pass Chat Completions options throughproviderOptions.openai:
store, serviceTier, parallelToolCalls, user,
stopSequences, frequencyPenalty, presencePenalty, and seed.
Known OpenAI models select their required token-limit parameter automatically.
Unknown model IDs use max_tokens, which has the broadest compatibility. Set
maxTokensParameter on createOpenAICompat() when every model exposed by the
endpoint requires a different parameter.