FG API Documentation

Real-time voice AI for business: speech recognition, dialogue, and synthesis in three HTTP calls. Base URL: http://localhost:4100/v1 (beta).

1. Get an API key

Sign up and create a key in the console. A key like fg-… is shown only once — save it.

2. Your first audio — in one command

curl http://localhost:4100/v1/audio/speech \
  -H "Authorization: Bearer $FG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fg-voice-1",
    "voice": "sergei",
    "input": "Sir, the platform is connected."
  }' --output hello.mp3 && open hello.mp3

3. The full voice loop

The assistant is a pipeline of three calls. Each step is its own endpoint, with your code in between:

  1. Transcribe: the user’s audio → POST /v1/audio/transcriptions → text;
  2. Think: text → POST /v1/chat/completions with stream: true → a reply, sentence by sentence;
  3. Speak: each sentence → POST /v1/audio/speech → mp3, played as it arrives.
The “instant response” trick: play a pre-recorded opener (“One sec…”, “Let me check…”) the moment the user stops speaking — while the pipeline prepares the first sentence, the pause goes unnoticed.

Authentication

Every request carries an Authorization: Bearer fg-… header. Keys are created and revoked in the console; we store only a fingerprint of the key.

Never embed a key in client-side code or repositories. Revoke a leaked key in the console — it takes effect instantly.

Model

GET/v1/models

fg-voice-1 — the flagship voice model for business assistants: real-time dialogue, sentence-by-sentence streaming.

{
  "object": "list",
  "data": [{ "id": "fg-voice-1", "object": "model", "owned_by": "fg-ai" }]
}

Chat completions

POST/v1/chat/completions

Chat with the model. The format matches OpenAI: the same messages array, the same chat.completion response, the same chunked streaming. By default the model is tuned for speech: short phrases, no markdown.

ParameterTypeDescription
messagesrequiredarrayThe conversation: {role: "system"|"user"|"assistant", content: "…"}. Your own system replaces the assistant’s default persona.
modeloptionalstringfg-voice-1 (default).
streamoptionalbooleanSSE stream. Deltas arrive sentence by sentence — send each straight to speech synthesis.
max_tokensoptionalinteger1–4096, default 1024.
curl http://localhost:4100/v1/chat/completions \
  -H "Authorization: Bearer $FG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fg-voice-1",
    "stream": true,
    "messages": [
      { "role": "user", "content": "Summarize this week's sales" }
    ]
  }'

Response (stream: true)

# each data: is a whole sentence, ready for speech
data: {"object":"chat.completion.chunk", "choices":[{"delta":{"content":"Summary ready. "}}]}
data: {"object":"chat.completion.chunk", "choices":[{"delta":{"content":"Revenue is up eight percent. "}}]}
data: [DONE]

Speech synthesis

POST/v1/audio/speech

Text → audio/mpeg audio (mp3, 44.1 kHz). Latency is a fraction of a second — suitable for real-time replies.

ParameterTypeDescription
inputrequiredstringText up to 4096 characters. The language is detected automatically (ru/en).
voiceoptionalstringA voice name (sergei — default) or a voice ID from the catalog.
modeloptionalstringfg-voice-1.

Speech recognition

POST/v1/audio/transcriptions

Audio → text. multipart/form-data with a file field: webm/opus, mp3, wav, m4a. A built-in filter drops noise and recognition “hallucinations” — silence returns an empty text, and the assistant just keeps listening.

curl http://localhost:4100/v1/audio/transcriptions \
  -H "Authorization: Bearer $FG_API_KEY" \
  -F file=@question.webm \
  -F model=fg-voice-1
# → {"text": "What's the revenue this week?"}
ParameterTypeDescription
filerequiredfileAudio file up to 32 MB.
languageoptionalstringLanguage code (ru by default, en, …) — a hint that makes recognition faster and sharper.

Voices

A voice is chosen by name. In beta, sergei is available (Russian male, default) — the name library is growing. Advanced: pass the ID of any voice from our catalog (700+ voices).

Migrate from OpenAI

The API is compatible with OpenAI’s format. In the official SDK you change two lines — the base URL and the key:

import OpenAI from 'openai';

// before: new OpenAI({ apiKey: 'sk-…' })
const client = new OpenAI({
  baseURL: 'http://localhost:4100/v1',
  apiKey: process.env.FG_API_KEY,   // fg-…
});

// the rest of your code is unchanged:
const chat = await client.chat.completions.create({
  model: 'fg-voice-1',
  messages: [{ role: 'user', content: 'Hello!' }],
});
OpenAIFG
gpt-4o, gpt-4o-minifg-voice-1
voice: "alloy" / "verse"voice: "sergei"
whisper-1fg-voice-1 (you can leave the model field unchanged — it’s ignored)
Realtime API (WebRTC/WS)A cascade of three HTTP calls + an opener line (see Quickstart) — comparable UX without WebRTC

Errors & limits

Error format matches OpenAI: an HTTP status + JSON with error.type and error.code.

StatuscodeWhat to do
401missing_api_key / invalid_api_keyCheck the Authorization: Bearer fg-… header and that the key isn’t revoked.
400missing_input, unknown_voice, …The message names the specific field.
429daily_quota_exceededBeta: 2000 requests per day per account. The counter resets at midnight UTC.
5xxapi_errorRetry with exponential backoff.
Beta is free: $0 for every call within quota. We’ll announce paid plans in advance — existing keys will keep working.
Copied