Skip to main content
The Responses API is Mavera’s core endpoint for generating AI responses enhanced with persona intelligence. It produces audience-aware outputs that reflect how real demographics think, decide, and respond. The API follows the OpenAI Responses format, so you can use the OpenAI SDK with a two-line configuration change.
OpenAI SDK compatible. Any code written for client.responses.create() works with Mavera. Just change base_url and add a persona_id.

Key Features

Persona Intelligence

Inject specialized personas to get audience-aware responses from 50+ demographics

OpenAI Compatible

Works with any OpenAI SDK — Python, JavaScript, Go, Rust, and more

Streaming

Real-time token streaming via Server-Sent Events with named event types

Analysis Mode

Get structured insights with confidence scores, emotional analysis, and bias detection

Structured Outputs

Request JSON responses with custom schemas for type-safe integrations

Vision Support

Analyze images with multimodal capabilities via input arrays

Tool Calling

Define custom functions with a flat tool format, plus built-in server tools

Credits Tracking

Every response includes usage.credits_used for cost monitoring

Request Flow

Basic Usage

1

Install the OpenAI SDK

2

Initialize the client with Mavera's base URL

3

Make a response request with a persona

In the Python SDK, pass Mavera-specific fields like persona_id via extra_body. In the JavaScript SDK, pass them as top-level properties with a // @ts-ignore comment — the SDK forwards unknown fields automatically.

Persona Integration

Every Responses API request should include a persona_id to activate Mavera’s audience intelligence. The persona shapes the model’s perspective, language, values, and decision-making patterns.
Without a persona_id, the API still works but returns generic responses without audience-specific perspective.
persona_id is technically optional, but most Mavera features lose their value without it. Always pass a persona for audience-aware outputs.

Streaming

Enable real-time streaming for better UX in chat interfaces. Mavera streams tokens via Server-Sent Events (SSE) using named event types like response.output_text.delta.

SSE Event Types

The stream context manager in Python automatically handles connection lifecycle. In JavaScript, use stream.on() for event-based iteration and await stream.finalResponse() to get the completed response object.

Analysis Mode

Enable analysis mode for structured, quantified insights alongside the natural-language response. This is unique to Mavera — it layers behavioral analysis on top of the persona’s answer.
Analysis mode returns these fields in the analysis object:
Structured outputs (text format) and analysis_mode cannot be used together. Use text format for custom schemas, or analysis_mode for Mavera’s built-in analysis structure.

Structured Outputs

Request JSON responses with a specific structure using the text format parameter passed via extra_body. This provides type-safe, predictable outputs for downstream code.

Simple JSON Mode

Force the model to return valid JSON:

JSON Schema Mode

Define a strict schema for predictable, typed responses. This is ideal for pipelines where downstream code depends on a specific structure.
When using json_schema mode, the response includes both output[0].content[0].text (the JSON as a string) and parsed (the already-parsed JSON object). Use parsed to skip the parsing step.

Tool Calling (Function Calling)

Enable the model to call custom functions you define. The Responses API uses a flat tool format — tool properties like name, description, and parameters are top-level fields instead of nested under a function wrapper.

Defining Tools

Pass an array of tool definitions with JSON Schema parameters:

Handling Tool Calls

When the response contains function_call items, execute the functions locally and send results back using function_call_output:

Tool Choice

Control how the model uses tools:

Built-in Server Tools

Mavera provides server-side tools that execute automatically without client roundtrips: Server tool results appear in the server_tool_calls array of the response.

Image / Vision Input

Include images for visual analysis using the input array with input_image content blocks:
Images must be publicly accessible URLs. Supported formats: PNG, JPEG, GIF, WebP. Maximum file size: 20 MB.

Multi-turn Conversations

Use the input array with role-based messages for multi-turn conversations:

Error Handling

The API uses standard HTTP status codes and returns structured error responses.

Error Response Format

Common Error Codes

Retry Logic

Rate Limits and Credits

Rate Limits

Rate limit headers are included in every response:

Credit Costs

Credits used are always returned in response.usage.credits_used. Monitor this to stay within budget.
Use reasoning_effort: "low" and verbosity: "low" for cheaper, faster responses when you don’t need deep analysis.

Advanced Parameters

The instructions parameter replaces system messages. Instructions are appended to the persona’s built-in system prompt, so you don’t need to repeat persona context — just add task-specific guidance.

Response Format

Standard Response

Response with Analysis

Response with Tool Calls

Best Practices

Mavera’s value comes from persona intelligence. Without a persona_id, you get generic responses. Match the persona to your target audience for the most useful outputs.
The instructions parameter is appended to the persona’s built-in system prompt. Use it to set task context — for example: "You are a market research analyst interviewing this persona about brand loyalty." This gives the model both audience perspective and task direction without overriding the persona.
Use client.responses.stream() for any response that might exceed a few sentences. This dramatically improves perceived latency in user-facing applications.
When the response feeds into downstream code, use text format with json_schema to guarantee a predictable structure. This eliminates parsing errors.
Implement retry logic with exponential backoff for 429 and 5xx errors. Log usage.credits_used to monitor costs.
Use reasoning_effort: "high" for complex analysis and "low" for simple Q&A. This controls both quality and credit cost.
The Responses API uses a flat tool definition — name, description, and parameters are top-level fields in each tool object. Don’t nest them under a function key.

Next Steps

Personas

Explore 50+ pre-built personas and create custom ones

Focus Groups

Run simulated audience research at scale

Migration Guide

Migrate from the Responses API

API Reference

Full API specification