Electron — Chat Completions
Generate a chat completion with Electron. OpenAI-compatible
request/response shape — point any OpenAI SDK at
https://api.smallest.ai/waves/v1 and it just works.
Set stream: true to receive tokens via Server-Sent Events. With
stream_options: { include_usage: true }, the final SSE chunk
carries the usage block so token accounting is exact even on
client disconnects.
Tool calling follows OpenAI’s tools array convention. When you
provide a voice-agent-style system prompt, Electron emits a short
filler phrase in the assistant message content field alongside
tool_calls — see the Tool Calling guide
for the voice-agent pattern.
Examples
cURL
Python (pip install openai)
JavaScript / TypeScript (npm install openai)
Streaming with usage (Python)
Common gotchas
- Base URL is
/waves/v1, not/v1. The OpenAI SDK appends/chat/completionsfor you. stream_options.include_usage: trueis required for exact token accounting on streaming calls — the final SSE chunk carries theusageblock.n > 1andprompt_logprobsare rejected. Use multiple requests if you need parallel completions.- Auth header is
Authorization: Bearer $SMALLEST_API_KEY— get the key from the Smallest AI Console.
Authentication
API key authentication. Include your key as Authorization: Bearer YOUR_API_KEY. Access tokens are not accepted on this endpoint.
Headers
Enterprise plans only. Set to true to expire this request’s
content. Prompts and completions are deleted within 7 days; the
usage record (token counts, model, latency) is kept. Omit the
header to keep content. On other plans the header is ignored and
the request is processed normally.
See Zero Data Retention.
Request
Model ID. Currently only "electron".
Maximum output tokens. Combined input + output context ceiling is 32,768.
When true, response is text/event-stream. See the
Streaming guide.
Tool / function calling definitions. Forwarded verbatim to the
OpenAI-compatible upstream, so the standard OpenAI shape
({type: "function", function: {name, description, parameters}})
is the recommended form and is what the examples below use.
The wire schema is permissive (array<object>) — any tools payload
the upstream accepts will work. See Tool Calling
for details.
Output shape. {type: "text"} (default) or {type: "json_object"}.
Best-effort determinism.
Opaque end-user identifier. Not interpreted by Electron.
Response headers
Response
Non-streaming: standard OpenAI chat.completion object.
Streaming (stream: true): text/event-stream SSE — each
event is a chat.completion.chunk delta, terminated by
data: [DONE].