Skip to main content

Installation

Minimum: Node.js 18+ (for native fetch). The OpenAI SDK works with Mavera’s Responses API via baseURL override.

Install Troubleshooting

Install the official openai package. Avoid openai-api, openai-node, or similar. Verify with npm list openai.
The SDK supports both. Use "type": "module" in package.json for ESM, or require("openai") for CommonJS. For TypeScript, ensure moduleResolution is compatible.
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 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:
  1. baseURLbaseURL: "https://app.mavera.io/api/v1"
  2. apiKey — Use your Mavera key (starts with mvra_live_)
  3. model — Use mavera-1
  4. persona_id — Add persona_id: "..." to every responses.create() call (JavaScript accepts it directly; no extra_body)
Streaming, tools, and structured outputs work with minor adjustments. See Migrate OpenAI to Mavera.

Configuration

Store your API key in an environment variable: MAVERA_API_KEY

Responses API

Basic Usage

Streaming

With Analysis Mode

REST API Endpoints

For non-Chat endpoints, use fetch:

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.
Run: 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