Installation
fetch). The OpenAI SDK works with Mavera’s Responses API via baseURL override.
Install Troubleshooting
Wrong package
Wrong package
Install the official
openai package. Avoid openai-api, openai-node, or similar. Verify with npm list openai.ESM vs CommonJS
ESM vs CommonJS
The SDK supports both. Use
"type": "module" in package.json for ESM, or require("openai") for CommonJS. For TypeScript, ensure moduleResolution is compatible.TypeScript type errors for persona_id
TypeScript type errors for persona_id
The OpenAI types don’t include
persona_id. Add it directly to the request object; use // @ts-expect-error above the line, or extend the types if needed.Node version
Node version
Node 18+ required. Check with
node -v. For older Node, consider upgrading or using the REST API directly.Migrating from OpenAI
If you’re switching from OpenAI to Mavera, change only these:- baseURL —
baseURL: "https://app.mavera.io/api/v1" - apiKey — Use your Mavera key (starts with
mvra_live_) - model — Use
mavera-1 - persona_id — Add
persona_id: "..."to everyresponses.create()call (JavaScript accepts it directly; noextra_body)
Configuration
Responses API
Basic Usage
Streaming
With Analysis Mode
REST API Endpoints
For non-Chat endpoints, usefetch:
TypeScript Support
The SDK includes full TypeScript types:Error Handling
Edge Runtime / Vercel
Works in Edge Runtime environments:React / Next.js Example
Full Example Script (Node.js)
A runnable script: list personas, send a chat, print the response.MAVERA_API_KEY=mvra_live_xxx node mavera_chat.mjs "How do you feel about subscription pricing?"
Quickstart: Chat
First chat in 5 minutes
Migrate OpenAI → Mavera
Switching from OpenAI
Streaming Chat in React
React component for streaming
API Reference
Responses API spec