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
API key sent to the compatible endpoint.
Base URL for the compatible Chat Completions endpoint.
A configured OpenAI SDK client.
Whether to extract nonstandard
reasoning_content and reasoning response
fields. Defaults to true.How
generateObject() and streamObject() request structured output.
Defaults to tool for broad endpoint compatibility. Set this to native
when the endpoint supports strict JSON Schema response formats.Returns
OpenAICompatProvider with a single chatModel() method.
Generate text
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 native strict JSON Schema output can opt in:
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.