@mayurajs/provider-openai
v1.2.0
Published
OpenAI models for Mayura, through the official OpenAI SDK.
Readme
@mayurajs/provider-openai
OpenAI models for Mayura, through the official openai SDK and the Responses API.
npm install mayura @mayurajs/provider-openaiimport { createModels, defineAgent, z } from 'mayura';
import { openai } from '@mayurajs/provider-openai';
const models = createModels({
providers: [openai({ apiKey: process.env.OPENAI_API_KEY! })],
prices: { 'openai/gpt-5.1': { inputMicrosPerMillionTokens: 1_250_000, outputMicrosPerMillionTokens: 10_000_000 } },
maxCallCostMicros: 50_000,
});
const agent = defineAgent({
id: 'helper', version: '1', instructions: 'Answer in one sentence.', model: models.model('openai/gpt-5.1'), tools: [],
input: z.object({ question: z.string() }), output: z.object({ answer: z.string() }),
});
// Grant it as model:openai/gpt-5.1.- Credentials are options: nothing is read from the environment.
- The SDK's own retries are off; the registry's
retryoption retries and charges every attempt. - Tool inputs and structured output use strict JSON Schema, and streaming reports output text as it arrives.
- Runs can take a conversation history (
runtime.submit(agent, { input, history })), sent before the run's own messages on every call. catalogholds OpenAI's list prices on its date, used only withprices: 'catalog'.
See the model registry guide. Apache-2.0.
The optional gateway packages share gatewayProvider, gatewayCredential, GatewayOptions, GatewayBinding and GatewayProvider from this extension. See AI gateways for host prices, explicit discovery permissions and deferred qualification.
RAG embeddings
This provider exports openAIEmbeddings for scoped RAG ingestion and retrieval. See the RAG guide for explicit permissions, cost ceilings and sensitivity profiles. Development cases are authored; validation is deferred.
