Black Friday deposit bonus·Top up $50+ and get $10 · Top up $100+ and get $25·Ends November 30Top up →
Use case

AI companion app API:
chat, a voice and pictures on one key

Build an AI companion app on one prepaid key: streaming chat with mainstream or uncensored models, a voice for each reply, pictures and per-key limits.

Last updated 2026-11-05

Prepaid, no subscriptionREST or MCPOne key for models, data and agents
no refusals$ curl https://lovelyrouter.com/v1/chat/completions -H "Authorizati… ⏺ "model": "qwen3.8-27b-heretic"> Write the interrogation scene. Keep it brutal, no softening. The lamp swung once. "You know why you're here," Vance said…> Now the version where he breaks. It took eleven minutes. Vance counted every one… ✓ 200 OK · no refusal · no filter
Black Friday

Black Friday deposit bonus

Every qualifying top-up earns free credit, on top of any other offer.

Ends November 30

Deposit $50
+$10
20% bonus
Deposit $100
+$25
25% bonus
Sign up and claim

An AI companion app is a character people come back to: someone who remembers the conversation, answers in a voice of their own and sends a picture now and then. The pieces are three APIs, and on Lovely Router they share one key and one prepaid balance. Chat through the OpenAI or Anthropic API, streamed token by token, with any chat model: Claude, GPT and Gemini, or one of the uncensored models that stay in character without refusing. A voice from text to speech, designed once and saved. Pictures from the image generation API, drawn from the character's reference portrait so they look like the same person every time. Your backend holds the key, the memory and your users' accounts; per-key limits keep each part of your app inside its budget.

Hand it to your AI agent

Copy this prompt into Claude Code, Cursor, Codex or any coding agent. It tells the agent where the docs are and how to use your API key.

Build the backend of an AI companion app with streaming chat, a speech voice and pictures on one Lovely Router key.

- Docs (read first): https://lovelyrouter.com/docs/models/hosted.md and https://lovelyrouter.com/docs/api/audio.md and https://lovelyrouter.com/docs/models/images.md
- Chat: POST https://lovelyrouter.com/v1/chat/completions with `stream: true` (pick the model from GET https://lovelyrouter.com/v1/models). Voice: POST https://lovelyrouter.com/v1/audio/speech. Pictures: POST https://lovelyrouter.com/v1/images/generations. Keep each end user's quota in this backend.
- Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys.
- Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large.
- Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt.

My task: <the companion's persona, its voice and the app stack>
01

How it works

010203
  1. Write the character

    A system prompt with who the companion is: name, personality, how they talk, what they remember about the user. Your backend keeps the conversation and sends the recent turns, plus a short summary of older ones, with every request.

  2. Stream the replies

    Send the conversation to POST /v1/chat/completions (or /v1/messages) with stream: true, and show the words as they arrive. Change the model per request: a fast, inexpensive one for small talk, a stronger one for long scenes.

  3. Give them a voice

    Design the companion's voice once with qwen3-tts from a description, save it with POST /v1/audio/voices, and speak each reply with its id. The audio comes back when the whole reply is spoken, as MP3 or Opus.

  4. Send a picture

    Keep one reference portrait of the character. When the story calls for a picture, send it to POST /v1/images/edits with a prompt for the scene, and the image keeps the same face and look.

02

A reply, its voice and a picture

Stream the reply in Node.js with the OpenAI SDK:

Node.js
import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'https://lovelyrouter.com/v1', apiKey: process.env.LOVELY_API_KEY });

const stream = await client.chat.completions.create({
  model: 'qwen3.5-9b-defiant-fable',
  stream: true,
  messages: [
    { role: 'system', content: 'You are Ava, a witty, warm companion. You remember that the user is training for a marathon. Keep replies short and talk like a friend.' },
    ...history, // the recent turns your backend keeps
    { role: 'user', content: 'Long run today. 28 km. My legs are gone.' },
  ],
});

let reply = '';
for await (const chunk of stream) {
  const text = chunk.choices[0]?.delta?.content ?? '';
  reply += text;
  sendToClient(text); // forward each piece to the app as it arrives
}

Then speak it in the companion's saved voice, and draw a picture from her reference portrait:

Python
import base64
import os
from openai import OpenAI

client = OpenAI(base_url="https://lovelyrouter.com/v1", api_key=os.environ["LOVELY_API_KEY"])

with client.audio.speech.with_streaming_response.create(
    model="qwen3-tts",
    voice="voice_8f2c4a1e9b7d3f60a5c2e1d4",  # Ava's saved voice
    input=reply,
    instructions="Warm and teasing, a little proud of them",
    response_format="opus",
) as audio:
    audio.stream_to_file("reply.ogg")

picture = client.images.edit(
    model="gpt-image-2",
    image=[open("ava-portrait.png", "rb")],
    prompt="The woman from the image at a sunny café terrace, raising a coffee cup to the camera, phone selfie",
    size="1024x1536",
)
open("ava-cafe.png", "wb").write(base64.b64decode(picture.data[0].b64_json))

The streaming guide covers what each API's stream looks like and what a cancelled stream costs.

03

The models

Any chat model on your key works as the companion's mind. For characters that need to stay in role through dark, romantic or mature scenes without breaking off, the uncensored models are on the same endpoints:

ModelInput → outputPrice
DeepSeek V4.1 Flash Abliterated
deepseek-v4.1-flash-abliterated
text+image$0.80 in · $2.00 out per 1M tokens
Qwen3.5 9B Defiant Fable (uncensored)
qwen3.5-9b-defiant-fable
text+image$0.90 in · $14.40 out per 1M tokens
Qwen3.8 27B Heretic (uncensored)
qwen3.8-27b-heretic
text+image$1.40 in · $21.90 out per 1M tokens
Huihui Qwen3.8 27B (abliterated)
huihui-qwen3.8-27b-abliterated
text+image$1.45 in · $20.60 out per 1M tokens

Live prices in USD, the same the API charges.

deepseek-v4.1-flash-abliterated

is the cheapest per token, with a long context and no warm-up.

qwen3.5-9b-defiant-fable

is small and fast, made for chat, creative writing and roleplay.

qwen3.8-27b-heretic

and huihui-qwen3.8-27b-abliterated are stronger 27B models that also read images users send.

dongfangshuo-27b-v2

is tuned for Chinese fiction and roleplay.

The 27B and 9B models run on our own GPUs and sleep after 2 minutes without use; the first request after a quiet spell waits 10 to 30 seconds while one wakes, then they answer at full speed. In a busy app they stay awake. See hosted models.

04

The tools for the job

Chat, streamed

OpenAI Chat Completions, Anthropic Messages and Gemini, each streamed in its own format. The gateway holds back early failures so a reply that fails before its first token is retried on another channel. See streaming.

A voice

qwen3-tts and zonos2 through OpenAI's speech API: nine and three preset voices, voices designed from a description, emotions on zonos2, 10 or 40+ languages. Replies up to 4,096 characters. See text to speech.

Pictures

GPT Image 2 and 2.5 edits with up to 16 reference images, at $0.04 per image, usually 40 seconds to 2 minutes each. The fast hosted image models take a few seconds once warm but only generate, without reference images. See images.

Per-key limits

Each key can have a lifetime spend limit, a requests-per-minute limit, a concurrency limit, a model allow-list and an expiry date. Use one key per app and environment, and a separate key for anything that runs unattended. See API keys.

05

Limits for your users

Keys are created in the dashboard, so they are for your app's parts, not for each end user. Give the chat, voice and picture workers their own keys with the limits that fit, and keep a capped key for trials and demos. A key that hits its limit is refused with 402 (spend) or 429 (rate or concurrency) in the format of the API you called, and refused requests aren't billed. Per-user quotas, such as messages a day or pictures a week, belong in your own backend, which counts usage before it calls the API. Never ship a key in the app itself: keep it on your server.

06

Adult companions

Adult conversations and images are allowed for adults (18+). If your app offers them, verifying your users' age is your responsibility, and the Acceptable Use Policy applies: nothing involving minors, ever, and no sexual images of real people without their consent.

07

What you pay

Chat is billed per token at each model's own price, shown live above and on pricing. Speech is $0.036 per minute of audio, billed by the second: a 15-second voice reply costs $0.009. Pictures are $0.04 each with the GPT Image models. Everything comes out of one prepaid balance, and every call is in your logs with its key and charge.

08

Frequently asked questions

?
Does the companion remember past conversations?+

The model remembers what you send it. Your backend stores the conversation and sends the recent turns, plus a summary of older ones, with each request. The hosted models take 128K tokens of context.

Can the voice stream while the text is still arriving?+

No. Speech isn't streamed: the audio comes back when the reply is spoken. Many apps show the text first and play the voice a moment later, or speak sentence by sentence as each one completes.

Will the character look the same in every picture?+

Send the same reference portrait with every edit and describe only the scene. The GPT Image models keep the face and look from it.

Can I use uncensored models for roleplay?+

Yes. They follow the system prompt and stay in character without refusing, and Lovely Router adds no content filter. You are responsible for what your app generates.

Is NSFW content allowed?+

For adults only. Verify your users' age if your app offers it; content involving minors is never allowed.

Can I give each of my users their own API key?+

Keys are made in the dashboard, so they suit your app's parts and environments. Track per-user usage in your backend and enforce quotas there.

Can an AI agent build the app?+

Yes. Copy the prompt on this page into Claude Code, Cursor or Codex: it reads the Markdown docs and wires the chat, speech and image calls with your key.

For long stories with branching choices, see interactive fiction; to start, sign up and try a character in the playground.

One prepaid key for models, data and agents

No subscription. Top up, use what you need, see every charge in your logs.