Fix Node SDK issues
Use this reference when your backend proxy cannot fetch session config from Orga. Each section lists the exact error string and the remediation steps.
Missing or invalid API key
Errors
Error: API key is required
OrgaAIAuthenticationError: Invalid API keyFix
libs/orga.ts
import { OrgaAI } from '@orga-ai/node';
export const orga = new OrgaAI({
apiKey: process.env.ORGA_API_KEY!
});- Confirm
ORGA_API_KEYmatches the key from the dashboard. - Restart the server after updating environment variables.
401 Unauthorized / 403 Forbidden
Symptom – OrgaAIServerError: Failed to fetch ephemeral token: Unauthorized
Fix
- Regenerate the API key and update your secrets manager.
- Ensure the request hits
https://api.orga-ai.com/v1/realtime/client-secrets. - Log the outgoing
Authorizationheader (minus the key) to confirm it’s set.
Network or timeout errors
Error
FetchError: network timeout at: https://api.orga-ai.com/v1/realtime/client-secretsFix
const orga = new OrgaAI({
apiKey: process.env.ORGA_API_KEY!,
timeout: 20000, // 20s
});- Make sure your VPC/firewall allows outbound HTTPS to
api.orga-ai.com. - Retry with exponential backoff if you’re on flaky networks.
Handling 500s from Orga
Wrap your proxy route in a try/catch to avoid leaking stack traces:
app.get('/api/orga-client-secrets', async (_req, res) => {
try {
const config = await orga.getSessionConfig();
res.json(config);
} catch (error) {
console.error('Orga error', error);
res.status(500).json({ error: 'Internal server error' });
}
});Retry after a short delay—500s can occur during brief maintenance windows.
Debug mode
Enable verbose logs while diagnosing issues:
const orga = new OrgaAI({
apiKey: process.env.ORGA_API_KEY!,
debug: true,
});Server output:
[OrgaAI] Fetching session config...
[OrgaAI] Fetched ephemeral token: eyJhbGc...
[OrgaAI] Fetched ICE servers: 3Disable debug: true in production to avoid noisy logs.
Need a fresh setup instead? Follow the Node tutorial to recreate the proxy from scratch.
Last updated on