Skip to content

OpenAI ​

@anvia/openai turns OpenAI APIs into Anvia model contracts. Create the provider client once at the server boundary, choose the model capability the workflow needs, and pass that model into agents, completions, retrieval, or media pipelines.

ts
import { OpenAIClient } from '@anvia/openai'

export const openai = new OpenAIClient({
  apiKey: process.env.OPENAI_API_KEY,
})

Choose a model ​

WorkflowFactoryContinue with
Agents, completions, tools, and structured outputcompletionModel(...)Completions
Retrieval and semantic searchembeddingModel(...)Embeddings
Image creationimageGenerationModel(...)Media models
Text-to-speechaudioGenerationModel(...)Media models
Speech-to-texttranscriptionModel(...)Media models
Provider inventorylistModels()Model listing

OpenAI completion models use the Responses adapter by default when no custom baseUrl is configured. Choose the Chat adapter only when the target or workflow requires it; the differences are covered in Responses and Chat.

What the provider owns ​

The package maps Anvia requests, content, tool calls, streams, usage, and media results to and from OpenAI. The application still owns instructions, tool permissions, memory, tenant routing, credential storage, fallback policy, retries, and observability.

Keep those boundaries visible in code. A provider model should be an injected dependency, not the place where product behavior or authorization decisions are hidden.

Start here ​

  1. Install and configure the client.
  2. Create a completion model for an agent or direct request.
  3. Add only the additional capability models the workflow uses.
  4. Review the production checklist before shipping.

Built for Anvia.