Voice Chat SDKs
Add AI voice chat to your game or app. Record, send, hear back - one API call.
Download
Unity
Microphone recording, WAV encoding, UnityWebRequest upload, and AudioClip playback.
Godot
AudioEffectRecord capture, manual multipart upload, and AudioStreamWAV playback.
Unreal Engine
AudioCapture, WAV encoding, FHttpModule multipart upload, and SoundWave playback.
Next.js / React
useSparkVoiceChat hook + drop-in <SparkVoiceChat> component with Web Audio API recording and streaming playback.
How It Works
Every SDK follows the same flow. One HTTP call, three AI steps happen server-side:
On the server, your audio goes through three AI-powered steps:
All three steps are handled by SparkAI. No additional keys or services needed.
Getting Started
Before using any SDK, you need an API key:
Create an account
Sign in at sparkbrain.app with your Google account.
Create an app
In the dashboard, click "Create App" and choose API / Extension as the app type. Pick your platform (Chrome Extension, CLI Tool, or npm Package).
Copy your API key
Your key starts with spark_ai- and is shown only once. Copy it immediately.
Where to store your key
Never hardcode your API key in source code. Each platform has a secure storage method:
| Platform | Recommended Storage |
|---|---|
| Next.js / React | Add SPARK_AI_KEY=spark_ai-... to .env.local and read via process.env.SPARK_AI_KEY in a server-side API route. Never expose in client-side code. |
| Node.js / CLI | Export as SPARK_AI_KEY in your shell profile or .env file. Read via process.env.SPARK_AI_KEY. |
| npm Package | Accept the key as a constructor parameter. Document that consumers should set SPARK_AI_KEY in their .env. |
| Chrome Extension | Store in chrome.storage.local or inject at build time via your bundler. Add .env to .gitignore. |
| Unity | Store in a ScriptableObject asset excluded from version control, or load from a config file at runtime. |
| Godot | Use an @export variable set in the Inspector, or load from a .cfg file excluded from version control. |
| Unreal Engine | Set via the Details panel at the instance level, or load from a config file. Avoid committing keys in source files. |
Your API key authenticates via the X-Api-Key header. All rate limits and usage are tracked per key.
API Reference
Send audio, receive AI audio response. Requires a paid plan.
Request Headers
| Header | Value | |
|---|---|---|
X-Api-Key |
Your API key (spark_ai-...) |
REQUIRED |
Content-Type |
multipart/form-data |
REQUIRED |
Request Body (Form Data)
| Field | Type | Description |
|---|---|---|
audio |
File | WAV audio file, max 10MB REQUIRED |
sessionId |
String | Conversation session ID (for multi-turn context) |
userEmail |
String | User identifier (for per-user rate limits) |
Response (200 OK)
| Header | Description |
|---|---|
Content-Type |
audio/wav - raw WAV audio bytes in body |
X-Transcript |
URL-encoded transcript of what the user said |
X-AI-Response |
URL-encoded text of the AI response |
cURL Example
curl -X POST https://sparkbrain.app/api/voice-chat \
-H "X-Api-Key: $SPARK_AI_KEY" \
-F "[email protected]" \
-F "sessionId=my-session" \
--output response.wav
Unity
Add SparkVoiceChat.cs to any GameObject. Set your API key in the Inspector or load from a ScriptableObject - never hardcode it.
var voice = gameObject.AddComponent<SparkVoiceChat>();
voice.apiKey = myConfig.sparkAiKey; // load from ScriptableObject
voice.endpoint = "https://sparkbrain.app/api/voice-chat";
voice.OnTranscriptReceived += (t) => Debug.Log("You said: " + t);
voice.OnResponseReceived += (r) => Debug.Log("AI said: " + r);
voice.OnError += (e) => Debug.LogError(e);
// Start recording (call on button press)
voice.StartRecording();
// Stop and send to AI (call on button release)
voice.StopRecordingAndSend();
// Audio response plays automatically
Events: OnTranscriptReceived, OnResponseReceived, OnAudioPlayed, OnError
Godot
Add spark_voice_chat.gd as an AutoLoad or attach to a Node. Set your API key via the Inspector @export or load from a config file.
# Project Settings > Audio > Driver > Enable Input = true
# Add audio bus "Record" with AudioEffectRecord
var voice = $SparkVoiceChat
voice.api_key = my_config.spark_ai_key # set in Inspector or load from .cfg
voice.endpoint = "https://sparkbrain.app/api/voice-chat"
voice.transcript_received.connect(func(t): print("You: ", t))
voice.response_received.connect(func(r): print("AI: ", r))
voice.error.connect(func(e): push_error(e))
# Start recording
voice.start_recording()
# Stop and send to AI
voice.stop_and_send()
# Audio plays automatically via AudioStreamPlayer child
Signals: transcript_received, response_received, audio_played, error
Unreal Engine
Add the SparkVoiceChat component to any Actor. Enable the AudioCapture plugin.
// In your Actor's header
UPROPERTY(VisibleAnywhere)
USparkVoiceChat* VoiceChat;
// In BeginPlay() - set ApiKey via Details panel or load from config
VoiceChat = NewObject<USparkVoiceChat>(this);
VoiceChat->Endpoint = TEXT("https://sparkbrain.app/api/voice-chat");
VoiceChat->RegisterComponent();
VoiceChat->OnTranscriptReceived.AddDynamic(this, &AMyActor::HandleTranscript);
VoiceChat->OnResponseReceived.AddDynamic(this, &AMyActor::HandleResponse);
// Start recording
VoiceChat->StartRecording();
// Stop and send to AI
VoiceChat->StopRecordingAndSend();
// Audio plays automatically via PlaySound2D
All properties are Blueprint-exposed. Set ApiKey in the Details panel instead of hardcoding in source.
Next.js / React
Use the useSparkVoiceChat hook or the drop-in <SparkVoiceChat> component. Add SPARK_AI_KEY=spark_ai-... to your .env.local and pass it from a server component or API route.
import { useSparkVoiceChat } from './SparkVoiceChat';
function VoiceChat({ apiKey }: { apiKey: string }) {
const { startRecording, stopAndSend, isRecording, isProcessing,
transcript, aiResponse, error } = useSparkVoiceChat({
apiKey, // pass from server, never hardcode
endpoint: 'https://sparkbrain.app/api/voice-chat',
});
return (
<button onClick={isRecording ? stopAndSend : startRecording}
disabled={isProcessing}>
{isProcessing ? 'Thinking...' : isRecording ? 'Stop' : 'Speak'}
</button>
);
}
import { SparkVoiceChat } from './SparkVoiceChat';
// Drop-in with built-in UI
<SparkVoiceChat
apiKey={process.env.SPARK_AI_KEY!}
endpoint="https://sparkbrain.app/api/voice-chat"
/>
The hook gives full control. The component provides a ready-made button with transcript display. Keep your key in .env.local, not in source code.