Skip to main content

AI credentials API

Your own AI provider keys (STT, LLM, TTS, realtime). Only needed if you are not using MediaSFU-managed AI.

Endpoint: https://mediasfu.com/v1/aicredentials

Authenticate with Authorization: Bearer <api-username>:<api-key> from your server. Try every action and copy the request in the API Sandbox.

▶ Watch this: Answer a phone line with an AI agent, 2:40.

Add a credential​

POST https://mediasfu.com/v1/aicredentials with action: "create"

Store an AI provider key under a nickname.

Required fields​

FieldTypeDescriptionDefault
nickNametextNickname. A label you reference this credential by.
typeVOICE, VISIONCredential type"VOICE"
extra[service]OpenAI GPT-4, Anthropic Claude, Gemini, Deepgram, AssemblyAI, Whisper, ElevenLabs, Cartesia-TTS, OpenAI-TTS, OpenAI-Realtime, Gemini-LiveProvider. More providers, voices and options are in the dashboard's AI credentials wizard."OpenAI GPT-4"
apiKeytextProvider API key. The key from your AI provider. Sent over HTTPS.

Optional: Model​

Pin a specific model.

FieldTypeDescriptionDefault
extra[model]textModel. Optional. Leave empty for the provider default.
curl -X POST https://mediasfu.com/v1/aicredentials \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MEDIASFU_API_USERNAME:$MEDIASFU_API_KEY" \
-d '{"action":"create","nickName":"my-openai","type":"VOICE","extra":[{"key":"service","value":"OpenAI GPT-4"}],"apiKey":"your-api-key"}'

Example response:

{
"success": true,
"aiCredential": {
"nickName": "my-openai",
"type": "VOICE",
"status": "ACTIVE",
"apiKey": "****9f0e",
"extra": [
{
"key": "service",
"value": "OpenAI GPT-4"
}
]
}
}

Update a credential​

POST https://mediasfu.com/v1/aicredentials with action: "update"

Rotate the key for a nickname.

Required fields​

FieldTypeDescriptionDefault
nickNametextNickname. A label you reference this credential by.
typeVOICE, VISIONCredential type"VOICE"

Optional: Changes​

Provide a new key to rotate.

FieldTypeDescriptionDefault
apiKeytextProvider API key. The key from your AI provider. Sent over HTTPS.
curl -X POST https://mediasfu.com/v1/aicredentials \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MEDIASFU_API_USERNAME:$MEDIASFU_API_KEY" \
-d '{"action":"update","nickName":"my-openai","type":"VOICE"}'

Example response:

{
"success": true,
"aiCredential": {
"nickName": "my-openai",
"type": "VOICE",
"status": "ACTIVE",
"apiKey": "****9f0e",
"extra": [
{
"key": "service",
"value": "OpenAI GPT-4"
}
]
}
}

Delete a credential​

POST https://mediasfu.com/v1/aicredentials with action: "delete"

Remove a stored credential.

Required fields​

FieldTypeDescriptionDefault
nickNametextNickname. A label you reference this credential by.
curl -X POST https://mediasfu.com/v1/aicredentials \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MEDIASFU_API_USERNAME:$MEDIASFU_API_KEY" \
-d '{"action":"delete","nickName":"my-openai"}'

Example response:

{
"success": true,
"aiCredential": {
"nickName": "my-openai"
}
}

List / get​

GET https://mediasfu.com/v1/aicredentials with action: "get"

Retrieve records. Everything is optional — send as-is to list all.

No fields are required.

Optional: Filters​

All optional — narrow or page the results.

FieldTypeDescriptionDefault
startIndexnumberStart index0
pageSizenumber (10–50)Page size. Between 10 and 50.20
curl "https://mediasfu.com/v1/aicredentials?action=get" \
-H "Authorization: Bearer $MEDIASFU_API_USERNAME:$MEDIASFU_API_KEY"

Example response:

{
"success": true,
"aiCredentials": [
{
"nickName": "my-openai",
"type": "VOICE",
"status": "ACTIVE",
"apiKey": "****9f0e",
"extra": [
{
"key": "service",
"value": "OpenAI GPT-4"
}
]
}
],
"total": 1,
"totalCount": 1,
"startIndex": 0,
"pageSize": 20
}

See errors and response format for failure handling.