Llm

Connect a call to AI language model.
1session.llm(
2{
3 vendor: 'openai',
4 model: "gpt-4o-realtime-preview-2024-10-01",
5 auth: {
6 apiKey
7 },
8 actionHook: '/final',
9 eventHook: '/event',
10 toolHook: '/toolCall',
11 events: [
12 'conversation.item.*',
13 'response.audio_transcript.done',
14 'input_audio_buffer.committed'
15 ],
16 llmOptions: {
17 response_create: {
18 modalities: ['text', 'audio'],
19 instructions: 'Please assist the user with their request.',
20 voice: 'alloy',
21 output_audio_format: 'pcm16',
22 temperature: 0.8,
23 max_output_tokens: 4096,
24 },
25 session_update: {
26 tools: [
27 {
28 name: 'get_weather',
29 type: 'function',
30 description: 'Get the weather at a given location',
31 parameters: {
32 type: 'object',
33 properties: {
34 location: {
35 type: 'string',
36 description: 'Location to get the weather from',
37 },
38 scale: {
39 type: 'string',
40 enum: ['fahrenheit', 'celsius'],
41 },
42 },
43 required: ['location', 'scale'],
44 },
45 },
46 ],
47 tool_choice: 'auto',
48 input_audio_transcription: {
49 model: 'whisper-1',
50 },
51 turn_detection: {
52 type: 'server_vad',
53 threshold: 0.8,
54 prefix_padding_ms: 300,
55 silence_duration_ms: 500,
56 }
57 }
58 }
59})

Parameters

model
stringRequired

Name of the LLM model.

vendor
stringRequired

Name of the LLM vendor.

actionHook
string

Webhook that will be called when the LLM session ends.

auth
object

Object containing authentication credentials; format according to the model.

connectOptions
object

Object containing information such as the URI to connect to.

eventHook
string

Webhook that will be called when a requested LLM event happens (e.g., transcript).

events
array

Array of event names listing the events requested (wildcards allowed).

llmOptions
object

Object containing instructions for the LLM; format dependent on the LLM model.

toolHook
string

Webhook that will be called when the LLM wants to call a function.

The following LLMs are currently supported:

  • OpenAI Realtime API
  • Deepgram Voice Agent
  • Ultravox
  • ElevenLabs
  • Google Gemini Live API

Google Gemini Live

Set vendor: 'google' and supply a Gemini Live model (for example models/gemini-2.0-flash-live-001 or models/gemini-3.1-flash-live-preview). llmOptions.setup is forwarded verbatim to Google’s BidiGenerateContentSetup message after the websocket connects.

1session.llm({
2 vendor: 'google',
3 model: 'models/gemini-2.0-flash-live-001',
4 auth: { apiKey: process.env.GEMINI_API_KEY },
5 actionHook: '/final',
6 eventHook: '/event',
7 toolHook: '/toolCall',
8 connectOptions: {
9 host: 'generativelanguage.googleapis.com',
10 version: 'v1beta'
11 },
12 llmOptions: {
13 setup: {
14 generationConfig: {
15 speechConfig: {
16 voiceConfig: { prebuiltVoiceConfig: { voiceName: 'Aoede' } }
17 }
18 },
19 systemInstruction: {
20 parts: [{ text: 'You are a helpful assistant named Barbara.' }]
21 }
22 },
23 greeting: 'Greet the caller warmly and ask how you can help.',
24 sessionResumption: {}
25 }
26});

Google-specific llmOptions fields

setup
objectRequired

The BidiGenerateContentSetup object sent to Gemini right after the websocket connects. The model field is populated automatically from the verb’s model parameter. generationConfig.responseModalities is forced to audio.

greeting
string | object

Optional proactive greeting. When set, jambonz sends a text message to Gemini immediately after setup so the agent speaks first without waiting for the caller to speak. Accepts either a string or an object with a text field. The value is an instruction to the model, not the literal words — for example "Greet the caller warmly" rather than "Hello, how can I help?".

Implemented using realtimeInput.text so it works on both the 2.0 Live models and gemini-3.1-flash-live-preview. (On 3.1, clientContent is reserved for seeding history and does not trigger a model response, which is why realtimeInput.text is used.)

sessionResumption
object

Enable session resumption. Pass {} to opt in, or { handle: "..." } to resume a previous session. Resumption handles are delivered back to the application via llm_event sessionResumptionUpdate messages.

Example Applications

Please checkout the following example applications: