Start an ephemeral session

Updated

Starts a session with an agent configuration that you pass in the request.

Preview documentation

You're reading the Conversational AI Platform (Preview) docs. Switch to Main.
POST
https://preview.ai.agora.io/conversational-ai/v1/projects/{appid}/sessions/ephemeral

Use this endpoint to start a session without saving an agent first, for example to test a configuration. The request body is the same as Start a session, but with the agent configuration in agent instead of agent_id. The configuration isn't saved.

Path Parameters

appidstring
Required

The App ID of your project.

Header Parameters

Idempotency-Keystring

A unique key, so that retrying the request can't start a second session. If a session was already started with this key, the request fails with 409 and reason IdempotencyKeyConflict, and no new session starts. The API doesn't return the original response. To find the session, list sessions. Keep the same key when you retry; never switch keys.

Request Body

agentobject
Required

The agent configuration for this session. It has the same fields as Create an agent, except agent_name. The configuration isn't saved.

instructionsstring

The system instructions that define how the agent behaves. The model receives them as the first system message, before messages.

messagesarray<object>

Messages that start the conversation history. They follow instructions.

variablesobject

Every variable the agent uses, keyed by variable name. A name starts with a lowercase letter and contains up to 64 lowercase letters, digits, and underscores. Reference a variable as {{variable_name}} in instructions, messages, greeting.text, pipeline.llm.failure_message, pipeline.silence_config.content, and generated filler instructions. The agent doesn't store values: pass them in values when you start a session, or in each campaign contact. Expansion is single-pass, so a value that contains a placeholder isn't expanded again.

greetingobject

The message the agent speaks when a participant joins. If you omit it, the agent doesn't greet participants automatically.

pipelineobject

The models that power the agent: separate ASR, LLM, and TTS stages. When you pass a pipeline, llm and tts are required.

filler_wordsobject

Short phrases the agent says while it waits for the LLM to respond, such as when it waits for a tool call.

transportRTC | Telephony
Required

How the agent connects to the participant. Pass the fields of one transport type only.

typestring(RTC)
Required

rtc: The agent joins an RTC channel.

channelstring(RTC)
Required

The name of the RTC channel to join, 1 to 256 characters.

tokenstring(RTC)

The RTC token the agent uses to join the channel. Required when the project has an App Certificate enabled. To renew it, update the session.

uidString | Integer(RTC)

The user ID the agent uses in the channel. Pass a string of up to 255 characters, such as "1002" or "agent-bot", or an integer from 0 to 4294967295, such as 1002. Omit it, or pass 0, to let Agora assign a user ID that differs from subscribe_uids.

subscribe_uidsarray<String | Integer>(RTC)
Required

The user ID of the participant the agent talks to, as a string or an integer. Pass exactly one user ID.

audio_scenariostring(RTC)

The audio scenario of the agent in the channel:

  • aiserver: Optimized for latency and network resilience in conversations with an agent.
  • chorus: For participants with good network conditions who need ultra-low latency.
encryptionobject(RTC)

Media encryption for the RTC channel. These values are never returned.

typestring(Telephony)
Required

telephony: The agent places a phone call.

fromstring(Telephony)
Required

The number_id of the number in the project to call from. Phone numbers aren't accepted. Import the number first.

tostring(Telephony)
Required

The phone number to call, in E.164 format, for example +14155550100.

call_policyobject(Telephony)

Limits and behavior for outbound phone calls. Each limit you omit adds no limit.

valuesobject

Values for the agent's variables, keyed by variable name, for this session only. Each key must be a variable the agent declares, and each value must match its type and options. Pass a value for every required variable. null values are rejected.

lifecycleobject

When the session ends on its own.

data_policyobject

How Agora handles the session's data. You set it when the session starts and can't change it afterward.

labelsobject

Key-value labels for this session, such as a team or customer ID. They're included in the payload of notification events.

Response Body

The session was created.

Response Headers

Agora-Request-Idstring

A unique ID for the request. Include it when you contact Agora support.

agent_session_idstring
Required

The ID of the session.

create_tsinteger
Required

The time the session was created, as a Unix timestamp in seconds.

statusstring
Required

The status of the session when it starts. For a phone call, RUNNING doesn't mean the call was answered.

Authorization

This endpoint requires authentication.

Request examples

Example Request
curl -X POST 'https://preview.ai.agora.io/conversational-ai/v1/projects/string/sessions/ephemeral' \  -H 'Content-Type: application/json' \  -d '{  "agent": {    "instructions": "Answer account questions concisely.",    "pipeline": {      "mode": "cascaded",      "asr": {        "credential": {          "mode": "managed"        },        "vendor": "deepgram",        "model": "nova-3",        "language": "en-US"      },      "llm": {        "credential": {          "mode": "byok",          "fields": {            "api_key": "$secrets.support_prod.llm"          }        },        "vendor": "openai",        "style": "openai",        "model": "<model_name>"      },      "tts": {        "credential": {          "mode": "managed"        },        "vendor": "minimax",        "params": {          "model": "speech-2.6-turbo",          "voice_setting": {            "voice_id": "English_captivating_female1",            "speed": 1          }        }      }    }  },  "transport": {    "type": "rtc",    "channel": "support-4821",    "token": "<your_rtc_token>",    "uid": "1002",    "subscribe_uids": [      "1001"    ]  }}'

Response example

Example Response
{  "agent_session_id": "a42al97tw77hv93ja98dm74fk56lw97x",  "create_ts": 1737111452,  "status": "RUNNING"}