@livekit/agents-plugin-openai 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/llm.cjs +2 -2
- package/dist/llm.cjs.map +1 -1
- package/dist/llm.js +2 -2
- package/dist/llm.js.map +1 -1
- package/dist/realtime/api_proto.cjs.map +1 -1
- package/dist/realtime/api_proto.d.cts +6 -2
- package/dist/realtime/api_proto.d.ts +6 -2
- package/dist/realtime/api_proto.d.ts.map +1 -1
- package/dist/realtime/api_proto.js.map +1 -1
- package/dist/realtime/realtime_model.cjs +16 -30
- package/dist/realtime/realtime_model.cjs.map +1 -1
- package/dist/realtime/realtime_model.d.cts +3 -1
- package/dist/realtime/realtime_model.d.ts +3 -1
- package/dist/realtime/realtime_model.d.ts.map +1 -1
- package/dist/realtime/realtime_model.js +14 -29
- package/dist/realtime/realtime_model.js.map +1 -1
- package/dist/realtime/realtime_model.test.cjs +106 -0
- package/dist/realtime/realtime_model.test.cjs.map +1 -0
- package/dist/realtime/realtime_model.test.d.cts +2 -0
- package/dist/realtime/realtime_model.test.d.ts +2 -0
- package/dist/realtime/realtime_model.test.d.ts.map +1 -0
- package/dist/realtime/realtime_model.test.js +105 -0
- package/dist/realtime/realtime_model.test.js.map +1 -0
- package/dist/realtime/realtime_model_beta.cjs +0 -26
- package/dist/realtime/realtime_model_beta.cjs.map +1 -1
- package/dist/realtime/realtime_model_beta.d.cts +0 -1
- package/dist/realtime/realtime_model_beta.d.ts +0 -1
- package/dist/realtime/realtime_model_beta.d.ts.map +1 -1
- package/dist/realtime/realtime_model_beta.js +0 -26
- package/dist/realtime/realtime_model_beta.js.map +1 -1
- package/dist/stt.cjs +2 -2
- package/dist/stt.cjs.map +1 -1
- package/dist/stt.js +2 -2
- package/dist/stt.js.map +1 -1
- package/dist/tts.cjs +2 -2
- package/dist/tts.cjs.map +1 -1
- package/dist/tts.js +2 -2
- package/dist/tts.js.map +1 -1
- package/package.json +7 -7
- package/src/llm.ts +2 -2
- package/src/realtime/api_proto.ts +12 -2
- package/src/realtime/realtime_model.test.ts +129 -0
- package/src/realtime/realtime_model.ts +28 -36
- package/src/realtime/realtime_model_beta.ts +2 -31
- package/src/stt.ts +2 -2
- package/src/tts.ts +2 -2
package/dist/llm.cjs
CHANGED
|
@@ -54,8 +54,8 @@ class LLM extends import_agents.llm.LLM {
|
|
|
54
54
|
throw new Error("OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY");
|
|
55
55
|
}
|
|
56
56
|
this.#client = this.#opts.client || new import_openai.OpenAI({
|
|
57
|
-
baseURL: opts.baseURL,
|
|
58
|
-
apiKey: opts.apiKey
|
|
57
|
+
baseURL: this.#opts.baseURL,
|
|
58
|
+
apiKey: this.#opts.apiKey
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
label() {
|
package/dist/llm.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { AzureOpenAI, OpenAI } from 'openai';\nimport type {\n CerebrasChatModels,\n ChatModels,\n DeepSeekChatModels,\n GroqChatModels,\n MetaChatModels,\n OctoChatModels,\n PerplexityChatModels,\n TelnyxChatModels,\n TogetherChatModels,\n XAIChatModels,\n} from './models.js';\n\nexport interface LLMOptions {\n model: string | ChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nconst defaultAzureLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.AZURE_API_KEY,\n strictToolSchema: false,\n};\n\nexport class LLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n /**\n * Create a new instance of OpenAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OpenAI API key, either using the argument or by setting the\n * `OPENAI_API_KEY` environment variable.\n */\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: opts.baseURL,\n apiKey: opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n /**\n * Create a new instance of OpenAI LLM with Azure.\n *\n * @remarks\n * This automatically infers the following arguments from their corresponding environment variables if they are not provided:\n * - `apiKey` from `AZURE_OPENAI_API_KEY`\n * - `organization` from `OPENAI_ORG_ID`\n * - `project` from `OPENAI_PROJECT_ID`\n * - `azureAdToken` from `AZURE_OPENAI_AD_TOKEN`\n * - `apiVersion` from `OPENAI_API_VERSION`\n * - `azureEndpoint` from `AZURE_OPENAI_ENDPOINT`\n */\n static withAzure(\n opts: {\n model: string | ChatModels;\n azureEndpoint?: string;\n azureDeployment?: string;\n apiVersion?: string;\n apiKey?: string;\n azureAdToken?: string;\n azureAdTokenProvider?: () => Promise<string>;\n organization?: string;\n project?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n } = defaultAzureLLMOptions,\n ): LLM {\n opts = { ...defaultAzureLLMOptions, ...opts };\n if (opts.apiKey === undefined) {\n throw new Error('Azure API key is required, whether as an argument or as $AZURE_API_KEY');\n }\n\n return new LLM({\n temperature: opts.temperature,\n user: opts.user,\n client: new AzureOpenAI(opts),\n });\n }\n\n /**\n * Create a new instance of Cerebras LLM.\n *\n * @remarks\n * `apiKey` must be set to your Cerebras API key, either using the argument or by setting the\n * `CEREBRAS_API_KEY` environment variable.\n */\n static withCerebras(\n opts: Partial<{\n model: string | CerebrasChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.CEREBRAS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Cerebras API key is required, whether as an argument or as $CEREBRAS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama3.1-8b',\n baseURL: 'https://api.cerebras.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Fireworks LLM.\n *\n * @remarks\n * `apiKey` must be set to your Fireworks API key, either using the argument or by setting the\n * `FIREWORKS_API_KEY` environment variable.\n */\n static withFireworks(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.FIREWORKS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Fireworks API key is required, whether as an argument or as $FIREWORKS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'accounts/fireworks/models/llama-v3p1-70b-instruct',\n baseURL: 'https://api.fireworks.ai/inference/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of xAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your xAI API key, either using the argument or by setting the\n * `XAI_API_KEY` environment variable.\n */\n static withXAI(\n opts: Partial<{\n model: string | XAIChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.XAI_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('xAI API key is required, whether as an argument or as $XAI_API_KEY');\n }\n\n return new LLM({\n model: 'grok-2-public',\n baseURL: 'https://api.x.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Groq LLM.\n *\n * @remarks\n * `apiKey` must be set to your Groq API key, either using the argument or by setting the\n * `GROQ_API_KEY` environment variable.\n */\n static withGroq(\n opts: Partial<{\n model: string | GroqChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.GROQ_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Groq API key is required, whether as an argument or as $GROQ_API_KEY');\n }\n\n return new LLM({\n model: 'llama3-8b-8192',\n baseURL: 'https://api.groq.com/openai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of DeepSeek LLM.\n *\n * @remarks\n * `apiKey` must be set to your DeepSeek API key, either using the argument or by setting the\n * `DEEPSEEK_API_KEY` environment variable.\n */\n static withDeepSeek(\n opts: Partial<{\n model: string | DeepSeekChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.DEEPSEEK_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'DeepSeek API key is required, whether as an argument or as $DEEPSEEK_API_KEY',\n );\n }\n\n return new LLM({\n model: 'deepseek-chat',\n baseURL: 'https://api.deepseek.com/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of OctoAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OctoAI API key, either using the argument or by setting the\n * `OCTOAI_TOKEN` environment variable.\n */\n static withOcto(\n opts: Partial<{\n model: string | OctoChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.OCTOAI_TOKEN;\n if (opts.apiKey === undefined) {\n throw new Error('OctoAI API key is required, whether as an argument or as $OCTOAI_TOKEN');\n }\n\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n ...opts,\n });\n }\n\n /** Create a new instance of Ollama LLM. */\n static withOllama(\n opts: Partial<{\n model: string;\n baseURL?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n apiKey: 'ollama',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of PerplexityAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your PerplexityAI API key, either using the argument or by setting the\n * `PERPLEXITY_API_KEY` environment variable.\n */\n static withPerplexity(\n opts: Partial<{\n model: string | PerplexityChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.PERPLEXITY_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'PerplexityAI API key is required, whether as an argument or as $PERPLEXITY_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama-3.1-sonar-small-128k-chat',\n baseURL: 'https://api.perplexity.ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of TogetherAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your TogetherAI API key, either using the argument or by setting the\n * `TOGETHER_API_KEY` environment variable.\n */\n static withTogether(\n opts: Partial<{\n model: string | TogetherChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TOGETHER_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'TogetherAI API key is required, whether as an argument or as $TOGETHER_API_KEY',\n );\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',\n baseURL: 'https://api.together.xyz/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Telnyx LLM.\n *\n * @remarks\n * `apiKey` must be set to your Telnyx API key, either using the argument or by setting the\n * `TELNYX_API_KEY` environment variable.\n */\n static withTelnyx(\n opts: Partial<{\n model: string | TelnyxChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TELNYX_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Telnyx API key is required, whether as an argument or as $TELNYX_API_KEY');\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-70B-Instruct',\n baseURL: 'https://api.telnyx.com/v2/ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Meta Llama LLM.\n *\n * @remarks\n * `apiKey` must be set to your Meta Llama API key, either using the argument or by setting the\n * `LLAMA_API_KEY` environment variable.\n */\n static withMeta(\n opts: Partial<{\n apiKey?: string;\n baseURL?: string;\n client?: OpenAI;\n model?: string | MetaChatModels;\n temperature?: number;\n user?: string;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.LLAMA_API_KEY;\n opts.baseURL = opts.baseURL || 'https://api.llama.com/compat/v1/';\n opts.model = opts.model || 'Llama-4-Maverick-17B-128E-Instruct-FP8';\n\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Meta Llama API key is required, either as argument or set LLAMA_API_KEY environment variable',\n );\n }\n\n return new LLM(opts);\n }\n\n /**\n * Create a new instance of OVHcloud AI Endpoints LLM.\n *\n * @remarks\n * `apiKey` must be set to your OVHcloud AI Endpoints API key, either using the argument or by setting the\n * `OVHCLOUD_API_KEY` environment variable.\n */\n static withOVHcloud(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.OVHCLOUD_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'OVHcloud AI Endpoints API key is required, whether as an argument or as $OVHCLOUD_API_KEY',\n );\n }\n\n return new LLM({\n model: 'gpt-oss-120b',\n baseURL: 'https://oai.endpoints.kepler.ai.cloud.ovh.net/v1',\n ...opts,\n });\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n client: this.#client,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA4D;AAC5D,oBAAoC;AA8BpC,MAAM,oBAAgC;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI;AAAA,EACpB,mBAAmB;AAAA,EACnB,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AAI,KAAK,MAAM,aAAa;AAC1B,aAAO,cAAc,KAAK,MAAM;AAAA,IAClC;AAEA,QAAI,KAAK,MAAM,aAAa;AAC1B,aAAO,eAAe,KAAK,MAAM;AAAA,IACnC;AAEA,QAAI,KAAK,MAAM,UAAU,QAAW;AAClC,aAAO,QAAQ,KAAK,MAAM;AAAA,IAC5B;AAEA,wBACE,sBAAsB,SAAY,oBAAoB,KAAK,MAAM;AACnE,QAAI,WAAW,OAAO,KAAK,OAAO,EAAE,SAAS,KAAK,sBAAsB,QAAW;AACjF,aAAO,sBAAsB;AAAA,IAC/B;AAEA,iBAAa,eAAe,SAAY,aAAa,KAAK,MAAM;AAChE,QAAI,YAAY;AACd,aAAO,cAAc;AAAA,IACvB;AAEA,WAAO,IAAI,UAAU,MAAkC;AAAA,MACrD,OAAO,KAAK,MAAM;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,kBAAkB,KAAK,MAAM,oBAAoB;AAAA,MACjD,gBAAgB;AAAA;AAAA,IAClB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,kBAAkB,wBAAU,UAAU;AAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { AzureOpenAI, OpenAI } from 'openai';\nimport type {\n CerebrasChatModels,\n ChatModels,\n DeepSeekChatModels,\n GroqChatModels,\n MetaChatModels,\n OctoChatModels,\n PerplexityChatModels,\n TelnyxChatModels,\n TogetherChatModels,\n XAIChatModels,\n} from './models.js';\n\nexport interface LLMOptions {\n model: string | ChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nconst defaultAzureLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.AZURE_API_KEY,\n strictToolSchema: false,\n};\n\nexport class LLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n /**\n * Create a new instance of OpenAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OpenAI API key, either using the argument or by setting the\n * `OPENAI_API_KEY` environment variable.\n */\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: this.#opts.baseURL,\n apiKey: this.#opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n /**\n * Create a new instance of OpenAI LLM with Azure.\n *\n * @remarks\n * This automatically infers the following arguments from their corresponding environment variables if they are not provided:\n * - `apiKey` from `AZURE_OPENAI_API_KEY`\n * - `organization` from `OPENAI_ORG_ID`\n * - `project` from `OPENAI_PROJECT_ID`\n * - `azureAdToken` from `AZURE_OPENAI_AD_TOKEN`\n * - `apiVersion` from `OPENAI_API_VERSION`\n * - `azureEndpoint` from `AZURE_OPENAI_ENDPOINT`\n */\n static withAzure(\n opts: {\n model: string | ChatModels;\n azureEndpoint?: string;\n azureDeployment?: string;\n apiVersion?: string;\n apiKey?: string;\n azureAdToken?: string;\n azureAdTokenProvider?: () => Promise<string>;\n organization?: string;\n project?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n } = defaultAzureLLMOptions,\n ): LLM {\n opts = { ...defaultAzureLLMOptions, ...opts };\n if (opts.apiKey === undefined) {\n throw new Error('Azure API key is required, whether as an argument or as $AZURE_API_KEY');\n }\n\n return new LLM({\n temperature: opts.temperature,\n user: opts.user,\n client: new AzureOpenAI(opts),\n });\n }\n\n /**\n * Create a new instance of Cerebras LLM.\n *\n * @remarks\n * `apiKey` must be set to your Cerebras API key, either using the argument or by setting the\n * `CEREBRAS_API_KEY` environment variable.\n */\n static withCerebras(\n opts: Partial<{\n model: string | CerebrasChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.CEREBRAS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Cerebras API key is required, whether as an argument or as $CEREBRAS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama3.1-8b',\n baseURL: 'https://api.cerebras.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Fireworks LLM.\n *\n * @remarks\n * `apiKey` must be set to your Fireworks API key, either using the argument or by setting the\n * `FIREWORKS_API_KEY` environment variable.\n */\n static withFireworks(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.FIREWORKS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Fireworks API key is required, whether as an argument or as $FIREWORKS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'accounts/fireworks/models/llama-v3p1-70b-instruct',\n baseURL: 'https://api.fireworks.ai/inference/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of xAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your xAI API key, either using the argument or by setting the\n * `XAI_API_KEY` environment variable.\n */\n static withXAI(\n opts: Partial<{\n model: string | XAIChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.XAI_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('xAI API key is required, whether as an argument or as $XAI_API_KEY');\n }\n\n return new LLM({\n model: 'grok-2-public',\n baseURL: 'https://api.x.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Groq LLM.\n *\n * @remarks\n * `apiKey` must be set to your Groq API key, either using the argument or by setting the\n * `GROQ_API_KEY` environment variable.\n */\n static withGroq(\n opts: Partial<{\n model: string | GroqChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.GROQ_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Groq API key is required, whether as an argument or as $GROQ_API_KEY');\n }\n\n return new LLM({\n model: 'llama3-8b-8192',\n baseURL: 'https://api.groq.com/openai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of DeepSeek LLM.\n *\n * @remarks\n * `apiKey` must be set to your DeepSeek API key, either using the argument or by setting the\n * `DEEPSEEK_API_KEY` environment variable.\n */\n static withDeepSeek(\n opts: Partial<{\n model: string | DeepSeekChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.DEEPSEEK_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'DeepSeek API key is required, whether as an argument or as $DEEPSEEK_API_KEY',\n );\n }\n\n return new LLM({\n model: 'deepseek-chat',\n baseURL: 'https://api.deepseek.com/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of OctoAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OctoAI API key, either using the argument or by setting the\n * `OCTOAI_TOKEN` environment variable.\n */\n static withOcto(\n opts: Partial<{\n model: string | OctoChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.OCTOAI_TOKEN;\n if (opts.apiKey === undefined) {\n throw new Error('OctoAI API key is required, whether as an argument or as $OCTOAI_TOKEN');\n }\n\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n ...opts,\n });\n }\n\n /** Create a new instance of Ollama LLM. */\n static withOllama(\n opts: Partial<{\n model: string;\n baseURL?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n apiKey: 'ollama',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of PerplexityAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your PerplexityAI API key, either using the argument or by setting the\n * `PERPLEXITY_API_KEY` environment variable.\n */\n static withPerplexity(\n opts: Partial<{\n model: string | PerplexityChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.PERPLEXITY_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'PerplexityAI API key is required, whether as an argument or as $PERPLEXITY_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama-3.1-sonar-small-128k-chat',\n baseURL: 'https://api.perplexity.ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of TogetherAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your TogetherAI API key, either using the argument or by setting the\n * `TOGETHER_API_KEY` environment variable.\n */\n static withTogether(\n opts: Partial<{\n model: string | TogetherChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TOGETHER_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'TogetherAI API key is required, whether as an argument or as $TOGETHER_API_KEY',\n );\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',\n baseURL: 'https://api.together.xyz/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Telnyx LLM.\n *\n * @remarks\n * `apiKey` must be set to your Telnyx API key, either using the argument or by setting the\n * `TELNYX_API_KEY` environment variable.\n */\n static withTelnyx(\n opts: Partial<{\n model: string | TelnyxChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TELNYX_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Telnyx API key is required, whether as an argument or as $TELNYX_API_KEY');\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-70B-Instruct',\n baseURL: 'https://api.telnyx.com/v2/ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Meta Llama LLM.\n *\n * @remarks\n * `apiKey` must be set to your Meta Llama API key, either using the argument or by setting the\n * `LLAMA_API_KEY` environment variable.\n */\n static withMeta(\n opts: Partial<{\n apiKey?: string;\n baseURL?: string;\n client?: OpenAI;\n model?: string | MetaChatModels;\n temperature?: number;\n user?: string;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.LLAMA_API_KEY;\n opts.baseURL = opts.baseURL || 'https://api.llama.com/compat/v1/';\n opts.model = opts.model || 'Llama-4-Maverick-17B-128E-Instruct-FP8';\n\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Meta Llama API key is required, either as argument or set LLAMA_API_KEY environment variable',\n );\n }\n\n return new LLM(opts);\n }\n\n /**\n * Create a new instance of OVHcloud AI Endpoints LLM.\n *\n * @remarks\n * `apiKey` must be set to your OVHcloud AI Endpoints API key, either using the argument or by setting the\n * `OVHCLOUD_API_KEY` environment variable.\n */\n static withOVHcloud(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.OVHCLOUD_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'OVHcloud AI Endpoints API key is required, whether as an argument or as $OVHCLOUD_API_KEY',\n );\n }\n\n return new LLM({\n model: 'gpt-oss-120b',\n baseURL: 'https://oai.endpoints.kepler.ai.cloud.ovh.net/v1',\n ...opts,\n });\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n client: this.#client,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n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,MAAM,UAAU;AACvB,aAAO,WAAW,KAAK,MAAM;AAAA,IAC/B;AAEA,QAAI,KAAK,MAAM,MAAM;AACnB,aAAO,OAAO,KAAK,MAAM;AAAA,IAC3B;AAEA,QAAI,KAAK,MAAM,qBAAqB;AAClC,aAAO,wBAAwB,KAAK,MAAM;AAAA,IAC5C;AAEA,QAAI,KAAK,MAAM,aAAa;AAC1B,aAAO,cAAc,KAAK,MAAM;AAAA,IAClC;AAEA,QAAI,KAAK,MAAM,aAAa;AAC1B,aAAO,eAAe,KAAK,MAAM;AAAA,IACnC;AAEA,QAAI,KAAK,MAAM,UAAU,QAAW;AAClC,aAAO,QAAQ,KAAK,MAAM;AAAA,IAC5B;AAEA,wBACE,sBAAsB,SAAY,oBAAoB,KAAK,MAAM;AACnE,QAAI,WAAW,OAAO,KAAK,OAAO,EAAE,SAAS,KAAK,sBAAsB,QAAW;AACjF,aAAO,sBAAsB;AAAA,IAC/B;AAEA,iBAAa,eAAe,SAAY,aAAa,KAAK,MAAM;AAChE,QAAI,YAAY;AACd,aAAO,cAAc;AAAA,IACvB;AAEA,WAAO,IAAI,UAAU,MAAkC;AAAA,MACrD,OAAO,KAAK,MAAM;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,kBAAkB,KAAK,MAAM,oBAAoB;AAAA,MACjD,gBAAgB;AAAA;AAAA,IAClB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,kBAAkB,wBAAU,UAAU;AAAC;","names":[]}
|
package/dist/llm.js
CHANGED
|
@@ -30,8 +30,8 @@ class LLM extends llm.LLM {
|
|
|
30
30
|
throw new Error("OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY");
|
|
31
31
|
}
|
|
32
32
|
this.#client = this.#opts.client || new OpenAI({
|
|
33
|
-
baseURL: opts.baseURL,
|
|
34
|
-
apiKey: opts.apiKey
|
|
33
|
+
baseURL: this.#opts.baseURL,
|
|
34
|
+
apiKey: this.#opts.apiKey
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
label() {
|
package/dist/llm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { AzureOpenAI, OpenAI } from 'openai';\nimport type {\n CerebrasChatModels,\n ChatModels,\n DeepSeekChatModels,\n GroqChatModels,\n MetaChatModels,\n OctoChatModels,\n PerplexityChatModels,\n TelnyxChatModels,\n TogetherChatModels,\n XAIChatModels,\n} from './models.js';\n\nexport interface LLMOptions {\n model: string | ChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nconst defaultAzureLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.AZURE_API_KEY,\n strictToolSchema: false,\n};\n\nexport class LLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n /**\n * Create a new instance of OpenAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OpenAI API key, either using the argument or by setting the\n * `OPENAI_API_KEY` environment variable.\n */\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: opts.baseURL,\n apiKey: opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n /**\n * Create a new instance of OpenAI LLM with Azure.\n *\n * @remarks\n * This automatically infers the following arguments from their corresponding environment variables if they are not provided:\n * - `apiKey` from `AZURE_OPENAI_API_KEY`\n * - `organization` from `OPENAI_ORG_ID`\n * - `project` from `OPENAI_PROJECT_ID`\n * - `azureAdToken` from `AZURE_OPENAI_AD_TOKEN`\n * - `apiVersion` from `OPENAI_API_VERSION`\n * - `azureEndpoint` from `AZURE_OPENAI_ENDPOINT`\n */\n static withAzure(\n opts: {\n model: string | ChatModels;\n azureEndpoint?: string;\n azureDeployment?: string;\n apiVersion?: string;\n apiKey?: string;\n azureAdToken?: string;\n azureAdTokenProvider?: () => Promise<string>;\n organization?: string;\n project?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n } = defaultAzureLLMOptions,\n ): LLM {\n opts = { ...defaultAzureLLMOptions, ...opts };\n if (opts.apiKey === undefined) {\n throw new Error('Azure API key is required, whether as an argument or as $AZURE_API_KEY');\n }\n\n return new LLM({\n temperature: opts.temperature,\n user: opts.user,\n client: new AzureOpenAI(opts),\n });\n }\n\n /**\n * Create a new instance of Cerebras LLM.\n *\n * @remarks\n * `apiKey` must be set to your Cerebras API key, either using the argument or by setting the\n * `CEREBRAS_API_KEY` environment variable.\n */\n static withCerebras(\n opts: Partial<{\n model: string | CerebrasChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.CEREBRAS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Cerebras API key is required, whether as an argument or as $CEREBRAS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama3.1-8b',\n baseURL: 'https://api.cerebras.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Fireworks LLM.\n *\n * @remarks\n * `apiKey` must be set to your Fireworks API key, either using the argument or by setting the\n * `FIREWORKS_API_KEY` environment variable.\n */\n static withFireworks(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.FIREWORKS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Fireworks API key is required, whether as an argument or as $FIREWORKS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'accounts/fireworks/models/llama-v3p1-70b-instruct',\n baseURL: 'https://api.fireworks.ai/inference/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of xAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your xAI API key, either using the argument or by setting the\n * `XAI_API_KEY` environment variable.\n */\n static withXAI(\n opts: Partial<{\n model: string | XAIChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.XAI_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('xAI API key is required, whether as an argument or as $XAI_API_KEY');\n }\n\n return new LLM({\n model: 'grok-2-public',\n baseURL: 'https://api.x.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Groq LLM.\n *\n * @remarks\n * `apiKey` must be set to your Groq API key, either using the argument or by setting the\n * `GROQ_API_KEY` environment variable.\n */\n static withGroq(\n opts: Partial<{\n model: string | GroqChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.GROQ_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Groq API key is required, whether as an argument or as $GROQ_API_KEY');\n }\n\n return new LLM({\n model: 'llama3-8b-8192',\n baseURL: 'https://api.groq.com/openai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of DeepSeek LLM.\n *\n * @remarks\n * `apiKey` must be set to your DeepSeek API key, either using the argument or by setting the\n * `DEEPSEEK_API_KEY` environment variable.\n */\n static withDeepSeek(\n opts: Partial<{\n model: string | DeepSeekChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.DEEPSEEK_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'DeepSeek API key is required, whether as an argument or as $DEEPSEEK_API_KEY',\n );\n }\n\n return new LLM({\n model: 'deepseek-chat',\n baseURL: 'https://api.deepseek.com/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of OctoAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OctoAI API key, either using the argument or by setting the\n * `OCTOAI_TOKEN` environment variable.\n */\n static withOcto(\n opts: Partial<{\n model: string | OctoChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.OCTOAI_TOKEN;\n if (opts.apiKey === undefined) {\n throw new Error('OctoAI API key is required, whether as an argument or as $OCTOAI_TOKEN');\n }\n\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n ...opts,\n });\n }\n\n /** Create a new instance of Ollama LLM. */\n static withOllama(\n opts: Partial<{\n model: string;\n baseURL?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n apiKey: 'ollama',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of PerplexityAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your PerplexityAI API key, either using the argument or by setting the\n * `PERPLEXITY_API_KEY` environment variable.\n */\n static withPerplexity(\n opts: Partial<{\n model: string | PerplexityChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.PERPLEXITY_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'PerplexityAI API key is required, whether as an argument or as $PERPLEXITY_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama-3.1-sonar-small-128k-chat',\n baseURL: 'https://api.perplexity.ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of TogetherAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your TogetherAI API key, either using the argument or by setting the\n * `TOGETHER_API_KEY` environment variable.\n */\n static withTogether(\n opts: Partial<{\n model: string | TogetherChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TOGETHER_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'TogetherAI API key is required, whether as an argument or as $TOGETHER_API_KEY',\n );\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',\n baseURL: 'https://api.together.xyz/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Telnyx LLM.\n *\n * @remarks\n * `apiKey` must be set to your Telnyx API key, either using the argument or by setting the\n * `TELNYX_API_KEY` environment variable.\n */\n static withTelnyx(\n opts: Partial<{\n model: string | TelnyxChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TELNYX_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Telnyx API key is required, whether as an argument or as $TELNYX_API_KEY');\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-70B-Instruct',\n baseURL: 'https://api.telnyx.com/v2/ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Meta Llama LLM.\n *\n * @remarks\n * `apiKey` must be set to your Meta Llama API key, either using the argument or by setting the\n * `LLAMA_API_KEY` environment variable.\n */\n static withMeta(\n opts: Partial<{\n apiKey?: string;\n baseURL?: string;\n client?: OpenAI;\n model?: string | MetaChatModels;\n temperature?: number;\n user?: string;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.LLAMA_API_KEY;\n opts.baseURL = opts.baseURL || 'https://api.llama.com/compat/v1/';\n opts.model = opts.model || 'Llama-4-Maverick-17B-128E-Instruct-FP8';\n\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Meta Llama API key is required, either as argument or set LLAMA_API_KEY environment variable',\n );\n }\n\n return new LLM(opts);\n }\n\n /**\n * Create a new instance of OVHcloud AI Endpoints LLM.\n *\n * @remarks\n * `apiKey` must be set to your OVHcloud AI Endpoints API key, either using the argument or by setting the\n * `OVHCLOUD_API_KEY` environment variable.\n */\n static withOVHcloud(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.OVHCLOUD_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'OVHcloud AI Endpoints API key is required, whether as an argument or as $OVHCLOUD_API_KEY',\n );\n }\n\n return new LLM({\n model: 'gpt-oss-120b',\n baseURL: 'https://oai.endpoints.kepler.ai.cloud.ovh.net/v1',\n ...opts,\n });\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n client: this.#client,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n"],"mappings":"AAIA,SAAS,6BAA6B,WAAW,WAAW;AAC5D,SAAS,aAAa,cAAc;AA8BpC,MAAM,oBAAgC;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI;AAAA,EACpB,mBAAmB;AAAA,EACnB,kBAAkB;AACpB;AAEA,MAAM,yBAAqC;AAAA,EACzC,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI;AAAA,EACpB,kBAAkB;AACpB;AAEO,MAAM,YAAY,IAAI,IAAI;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YACE,OAA4B,mBAC5B,cAAkC,UAClC;AACA,UAAM;AAEN,SAAK,QAAQ,EAAE,GAAG,mBAAmB,GAAG,KAAK;AAC7C,SAAK,eAAe;AACpB,QAAI,KAAK,MAAM,WAAW,QAAW;AACnC,YAAM,IAAI,MAAM,0EAA0E;AAAA,IAC5F;AAEA,SAAK,UACH,KAAK,MAAM,UACX,IAAI,OAAO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AI,UAAU,MAAkC;AAAA,MACrD,OAAO,KAAK,MAAM;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,kBAAkB,KAAK,MAAM,oBAAoB;AAAA,MACjD,gBAAgB;AAAA;AAAA,IAClB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,kBAAkB,UAAU,UAAU;AAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { AzureOpenAI, OpenAI } from 'openai';\nimport type {\n CerebrasChatModels,\n ChatModels,\n DeepSeekChatModels,\n GroqChatModels,\n MetaChatModels,\n OctoChatModels,\n PerplexityChatModels,\n TelnyxChatModels,\n TogetherChatModels,\n XAIChatModels,\n} from './models.js';\n\nexport interface LLMOptions {\n model: string | ChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nconst defaultAzureLLMOptions: LLMOptions = {\n model: 'gpt-4.1',\n apiKey: process.env.AZURE_API_KEY,\n strictToolSchema: false,\n};\n\nexport class LLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n /**\n * Create a new instance of OpenAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OpenAI API key, either using the argument or by setting the\n * `OPENAI_API_KEY` environment variable.\n */\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: this.#opts.baseURL,\n apiKey: this.#opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n /**\n * Create a new instance of OpenAI LLM with Azure.\n *\n * @remarks\n * This automatically infers the following arguments from their corresponding environment variables if they are not provided:\n * - `apiKey` from `AZURE_OPENAI_API_KEY`\n * - `organization` from `OPENAI_ORG_ID`\n * - `project` from `OPENAI_PROJECT_ID`\n * - `azureAdToken` from `AZURE_OPENAI_AD_TOKEN`\n * - `apiVersion` from `OPENAI_API_VERSION`\n * - `azureEndpoint` from `AZURE_OPENAI_ENDPOINT`\n */\n static withAzure(\n opts: {\n model: string | ChatModels;\n azureEndpoint?: string;\n azureDeployment?: string;\n apiVersion?: string;\n apiKey?: string;\n azureAdToken?: string;\n azureAdTokenProvider?: () => Promise<string>;\n organization?: string;\n project?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n } = defaultAzureLLMOptions,\n ): LLM {\n opts = { ...defaultAzureLLMOptions, ...opts };\n if (opts.apiKey === undefined) {\n throw new Error('Azure API key is required, whether as an argument or as $AZURE_API_KEY');\n }\n\n return new LLM({\n temperature: opts.temperature,\n user: opts.user,\n client: new AzureOpenAI(opts),\n });\n }\n\n /**\n * Create a new instance of Cerebras LLM.\n *\n * @remarks\n * `apiKey` must be set to your Cerebras API key, either using the argument or by setting the\n * `CEREBRAS_API_KEY` environment variable.\n */\n static withCerebras(\n opts: Partial<{\n model: string | CerebrasChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.CEREBRAS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Cerebras API key is required, whether as an argument or as $CEREBRAS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama3.1-8b',\n baseURL: 'https://api.cerebras.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Fireworks LLM.\n *\n * @remarks\n * `apiKey` must be set to your Fireworks API key, either using the argument or by setting the\n * `FIREWORKS_API_KEY` environment variable.\n */\n static withFireworks(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.FIREWORKS_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Fireworks API key is required, whether as an argument or as $FIREWORKS_API_KEY',\n );\n }\n\n return new LLM({\n model: 'accounts/fireworks/models/llama-v3p1-70b-instruct',\n baseURL: 'https://api.fireworks.ai/inference/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of xAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your xAI API key, either using the argument or by setting the\n * `XAI_API_KEY` environment variable.\n */\n static withXAI(\n opts: Partial<{\n model: string | XAIChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.XAI_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('xAI API key is required, whether as an argument or as $XAI_API_KEY');\n }\n\n return new LLM({\n model: 'grok-2-public',\n baseURL: 'https://api.x.ai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Groq LLM.\n *\n * @remarks\n * `apiKey` must be set to your Groq API key, either using the argument or by setting the\n * `GROQ_API_KEY` environment variable.\n */\n static withGroq(\n opts: Partial<{\n model: string | GroqChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.GROQ_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Groq API key is required, whether as an argument or as $GROQ_API_KEY');\n }\n\n return new LLM({\n model: 'llama3-8b-8192',\n baseURL: 'https://api.groq.com/openai/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of DeepSeek LLM.\n *\n * @remarks\n * `apiKey` must be set to your DeepSeek API key, either using the argument or by setting the\n * `DEEPSEEK_API_KEY` environment variable.\n */\n static withDeepSeek(\n opts: Partial<{\n model: string | DeepSeekChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.DEEPSEEK_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'DeepSeek API key is required, whether as an argument or as $DEEPSEEK_API_KEY',\n );\n }\n\n return new LLM({\n model: 'deepseek-chat',\n baseURL: 'https://api.deepseek.com/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of OctoAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your OctoAI API key, either using the argument or by setting the\n * `OCTOAI_TOKEN` environment variable.\n */\n static withOcto(\n opts: Partial<{\n model: string | OctoChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.OCTOAI_TOKEN;\n if (opts.apiKey === undefined) {\n throw new Error('OctoAI API key is required, whether as an argument or as $OCTOAI_TOKEN');\n }\n\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n ...opts,\n });\n }\n\n /** Create a new instance of Ollama LLM. */\n static withOllama(\n opts: Partial<{\n model: string;\n baseURL?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n return new LLM({\n model: 'llama-2-13b-chat',\n baseURL: 'https://text.octoai.run/v1',\n apiKey: 'ollama',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of PerplexityAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your PerplexityAI API key, either using the argument or by setting the\n * `PERPLEXITY_API_KEY` environment variable.\n */\n static withPerplexity(\n opts: Partial<{\n model: string | PerplexityChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.PERPLEXITY_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'PerplexityAI API key is required, whether as an argument or as $PERPLEXITY_API_KEY',\n );\n }\n\n return new LLM({\n model: 'llama-3.1-sonar-small-128k-chat',\n baseURL: 'https://api.perplexity.ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of TogetherAI LLM.\n *\n * @remarks\n * `apiKey` must be set to your TogetherAI API key, either using the argument or by setting the\n * `TOGETHER_API_KEY` environment variable.\n */\n static withTogether(\n opts: Partial<{\n model: string | TogetherChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TOGETHER_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'TogetherAI API key is required, whether as an argument or as $TOGETHER_API_KEY',\n );\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',\n baseURL: 'https://api.together.xyz/v1',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Telnyx LLM.\n *\n * @remarks\n * `apiKey` must be set to your Telnyx API key, either using the argument or by setting the\n * `TELNYX_API_KEY` environment variable.\n */\n static withTelnyx(\n opts: Partial<{\n model: string | TelnyxChatModels;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client: OpenAI;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.TELNYX_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error('Telnyx API key is required, whether as an argument or as $TELNYX_API_KEY');\n }\n\n return new LLM({\n model: 'meta-llama/Meta-Llama-3.1-70B-Instruct',\n baseURL: 'https://api.telnyx.com/v2/ai',\n ...opts,\n });\n }\n\n /**\n * Create a new instance of Meta Llama LLM.\n *\n * @remarks\n * `apiKey` must be set to your Meta Llama API key, either using the argument or by setting the\n * `LLAMA_API_KEY` environment variable.\n */\n static withMeta(\n opts: Partial<{\n apiKey?: string;\n baseURL?: string;\n client?: OpenAI;\n model?: string | MetaChatModels;\n temperature?: number;\n user?: string;\n }> = {},\n ): LLM {\n opts.apiKey = opts.apiKey || process.env.LLAMA_API_KEY;\n opts.baseURL = opts.baseURL || 'https://api.llama.com/compat/v1/';\n opts.model = opts.model || 'Llama-4-Maverick-17B-128E-Instruct-FP8';\n\n if (opts.apiKey === undefined) {\n throw new Error(\n 'Meta Llama API key is required, either as argument or set LLAMA_API_KEY environment variable',\n );\n }\n\n return new LLM(opts);\n }\n\n /**\n * Create a new instance of OVHcloud AI Endpoints LLM.\n *\n * @remarks\n * `apiKey` must be set to your OVHcloud AI Endpoints API key, either using the argument or by setting the\n * `OVHCLOUD_API_KEY` environment variable.\n */\n static withOVHcloud(opts: Partial<LLMOptions> = {}): LLM {\n opts.apiKey = opts.apiKey || process.env.OVHCLOUD_API_KEY;\n if (opts.apiKey === undefined) {\n throw new Error(\n 'OVHcloud AI Endpoints API key is required, whether as an argument or as $OVHCLOUD_API_KEY',\n );\n }\n\n return new LLM({\n model: 'gpt-oss-120b',\n baseURL: 'https://oai.endpoints.kepler.ai.cloud.ovh.net/v1',\n ...opts,\n });\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n client: this.#client,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n"],"mappings":"AAIA,SAAS,6BAA6B,WAAW,WAAW;AAC5D,SAAS,aAAa,cAAc;AA8BpC,MAAM,oBAAgC;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI;AAAA,EACpB,mBAAmB;AAAA,EACnB,kBAAkB;AACpB;AAEA,MAAM,yBAAqC;AAAA,EACzC,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI;AAAA,EACpB,kBAAkB;AACpB;AAEO,MAAM,YAAY,IAAI,IAAI;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YACE,OAA4B,mBAC5B,cAAkC,UAClC;AACA,UAAM;AAEN,SAAK,QAAQ,EAAE,GAAG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AAK,OAAO,EAAE,SAAS,KAAK,sBAAsB,QAAW;AACjF,aAAO,sBAAsB;AAAA,IAC/B;AAEA,iBAAa,eAAe,SAAY,aAAa,KAAK,MAAM;AAChE,QAAI,YAAY;AACd,aAAO,cAAc;AAAA,IACvB;AAEA,WAAO,IAAI,UAAU,MAAkC;AAAA,MACrD,OAAO,KAAK,MAAM;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,kBAAkB,KAAK,MAAM,oBAAoB;AAAA,MACjD,gBAAgB;AAAA;AAAA,IAClB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,kBAAkB,UAAU,UAAU;AAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/realtime/api_proto.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport const SAMPLE_RATE = 24000;\nexport const NUM_CHANNELS = 1;\nexport const IN_FRAME_SIZE = 2400; // 100ms\nexport const OUT_FRAME_SIZE = 1200; // 50ms\n\nexport const BASE_URL = 'wss://api.openai.com/v1';\n\nexport type Model = 'gpt-4o-realtime-preview-2024-10-01' | string; // Open-ended, for future models\nexport type Voice =\n | 'alloy'\n | 'shimmer'\n | 'echo'\n | 'ash'\n | 'ballad'\n | 'coral'\n | 'sage'\n | 'verse'\n | string;\n\n/** @deprecated Use LegacyAudioFormat for Beta API string format or AudioFormat for GA API object format */\nexport type LegacyAudioFormat = 'pcm16'; // TODO: 'g711-ulaw' | 'g711-alaw' (Beta format)\nexport type Role = 'system' | 'assistant' | 'user' | 'tool';\nexport type GenerationFinishedReason = 'stop' | 'max_tokens' | 'content_filter' | 'interrupt';\nexport type InputTranscriptionModel = 'whisper-1' | string; // Open-ended, for future models\nexport type Modality = 'text' | 'audio';\nexport type ToolChoice = 'auto' | 'none' | 'required' | string;\nexport type State = 'initializing' | 'listening' | 'thinking' | 'speaking' | string;\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'incomplete'\n | 'cancelled'\n | 'failed'\n | string;\nexport type ClientEventType =\n | 'session.update'\n | 'input_audio_buffer.append'\n | 'input_audio_buffer.commit'\n | 'input_audio_buffer.clear'\n | 'conversation.item.create'\n | 'conversation.item.truncate'\n | 'conversation.item.delete'\n | 'response.create'\n | 'response.cancel';\n\nexport type ServerEventType =\n | 'error'\n | 'session.created'\n | 'session.updated'\n | 'conversation.created'\n | 'input_audio_buffer.committed'\n | 'input_audio_buffer.cleared'\n | 'input_audio_buffer.speech_started'\n | 'input_audio_buffer.speech_stopped'\n | 'conversation.item.added' // GA: renamed from conversation.item.created\n | 'conversation.item.created' // Beta: kept for backward compatibility\n | 'conversation.item.input_audio_transcription.completed'\n | 'conversation.item.input_audio_transcription.failed'\n | 'conversation.item.truncated'\n | 'conversation.item.deleted'\n | 'response.created'\n | 'response.done'\n | 'response.output_item.added'\n | 'response.output_item.done'\n | 'response.content_part.added'\n | 'response.content_part.done'\n | 'response.output_text.delta' // GA: renamed from response.text.delta\n | 'response.output_text.done' // GA: renamed from response.text.done\n | 'response.text.delta' // Beta: kept for backward compatibility\n | 'response.text.done' // Beta: kept for backward compatibility\n | 'response.output_audio_transcript.delta' // GA: renamed from response.audio_transcript.delta\n | 'response.output_audio_transcript.done' // GA: renamed from response.audio_transcript.done\n | 'response.audio_transcript.delta' // Beta: kept for backward compatibility\n | 'response.audio_transcript.done' // Beta: kept for backward compatibility\n | 'response.output_audio.delta' // GA: renamed from response.audio.delta\n | 'response.output_audio.done' // GA: renamed from response.audio.done\n | 'response.audio.delta' // Beta: kept for backward compatibility\n | 'response.audio.done' // Beta: kept for backward compatibility\n | 'response.function_call_arguments.delta'\n | 'response.function_call_arguments.done'\n | 'rate_limits.updated';\n\nexport type AudioBase64Bytes = string;\n\nexport interface Tool {\n type: 'function';\n name: string;\n description?: string;\n parameters: {\n type: 'object';\n properties: {\n [prop: string]: {\n [prop: string]: any;\n };\n };\n required: string[];\n };\n}\n\nexport type TurnDetectionType =\n | {\n type: 'semantic_vad';\n eagerness?: 'auto' | 'low' | 'medium' | 'high'; // default: auto\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n }\n | {\n type: 'server_vad';\n threshold?: number; // 0.0 to 1.0, default: 0.5\n prefix_padding_ms?: number; // default: 300\n silence_duration_ms?: number; // default: 200\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n };\n\nexport type InputAudioTranscription = {\n model: InputTranscriptionModel;\n language?: string;\n prompt?: string;\n};\n\nexport type NoiseReductionType = 'near_field' | 'far_field';\n\nexport interface NoiseReduction {\n type: NoiseReductionType;\n}\n\nexport interface AudioFormat {\n type: 'audio/pcm';\n rate: number;\n}\n\nexport interface RealtimeAudioConfigInput {\n format?: AudioFormat;\n noise_reduction?: NoiseReduction | null;\n transcription?: InputAudioTranscription | null;\n turn_detection?: TurnDetectionType | null;\n}\n\nexport interface RealtimeAudioConfigOutput {\n format?: AudioFormat;\n speed?: number;\n voice?: Voice;\n}\n\nexport interface RealtimeAudioConfig {\n input?: RealtimeAudioConfigInput;\n output?: RealtimeAudioConfigOutput;\n}\n\nexport interface InputTextContent {\n type: 'input_text';\n text: string;\n}\n\nexport interface InputAudioContent {\n type: 'input_audio';\n audio: AudioBase64Bytes;\n}\n\nexport interface TextContent {\n type: 'text';\n text: string;\n}\n\nexport interface AudioContent {\n type: 'audio';\n audio: AudioBase64Bytes;\n transcript: string;\n}\n\nexport type Content = InputTextContent | InputAudioContent | TextContent | AudioContent;\nexport type ContentPart = {\n type: 'text' | 'audio' | 'output_text' | 'output_audio'; // GA: output_text/output_audio\n audio?: AudioBase64Bytes;\n transcript?: string;\n text?: string; // GA: text field for output_text\n};\n\nexport interface BaseItem {\n id: string;\n object: 'realtime.item';\n type: string;\n}\n\nexport interface SystemItem extends BaseItem {\n type: 'message';\n role: 'system';\n content: InputTextContent;\n}\n\nexport interface UserItem extends BaseItem {\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItem extends BaseItem {\n type: 'message';\n role: 'assistant';\n content: (TextContent | AudioContent)[];\n}\n\nexport interface FunctionCallItem extends BaseItem {\n type: 'function_call';\n call_id: string;\n name: string;\n arguments: string;\n}\n\nexport interface FunctionCallOutputItem extends BaseItem {\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ItemResource =\n | SystemItem\n | UserItem\n | AssistantItem\n | FunctionCallItem\n | FunctionCallOutputItem;\n\n// Session Resource\nexport interface SessionResource {\n id: string;\n object: 'realtime.session';\n model: string;\n modalities: Modality[]; // default: [\"text\", \"audio\"]\n instructions: string;\n voice: Voice; // default: \"alloy\"\n input_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n output_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n tools: Tool[];\n tool_choice: ToolChoice; // default: \"auto\"\n temperature: number; // default: 0.8\n max_response_output_tokens: number | 'inf';\n expires_at: number;\n}\n\n// Conversation Resource\nexport interface ConversationResource {\n id: string;\n object: 'realtime.conversation';\n}\n\nexport type ResponseStatusDetails =\n | {\n type: 'incomplete';\n reason: 'max_output_tokens' | 'content_filter' | string;\n }\n | {\n type: 'failed';\n error?: {\n code: 'server_error' | 'rate_limit_exceeded' | string;\n message: string;\n };\n }\n | {\n type: 'cancelled';\n reason: 'turn_detected' | 'client_cancelled' | string;\n };\n\nexport interface ModelUsage {\n total_tokens: number;\n input_tokens: number;\n output_tokens: number;\n input_token_details: {\n text_tokens: number;\n audio_tokens: number;\n cached_tokens: number;\n cached_tokens_details: {\n text_tokens: number;\n audio_tokens: number;\n image_tokens: number;\n };\n };\n output_token_details: {\n text_tokens: number;\n audio_tokens: number;\n };\n}\n\nexport interface ResponseResource {\n id: string;\n object: 'realtime.response';\n status: ResponseStatus;\n status_details: ResponseStatusDetails;\n output: ItemResource[];\n usage?: ModelUsage;\n metadata?: Record<string, string>;\n}\n\n// Client Events\ninterface BaseClientEvent {\n event_id?: string;\n type: ClientEventType;\n}\n\nexport interface SessionUpdateEvent extends BaseClientEvent {\n type: 'session.update';\n session: Partial<{\n // GA fields\n type?: 'realtime'; // GA: session type\n output_modalities?: Modality[]; // GA: renamed from modalities\n audio?: RealtimeAudioConfig; // GA: nested audio config\n max_output_tokens?: number | 'inf'; // GA: renamed from max_response_output_tokens\n tracing?: TracingConfig | null; // GA: tracing config\n // Common fields\n model: Model;\n instructions: string;\n tools: Tool[];\n tool_choice: ToolChoice;\n // Beta fields (kept for backward compatibility)\n modalities: Modality[];\n voice: Voice;\n input_audio_format: LegacyAudioFormat;\n output_audio_format: LegacyAudioFormat;\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n temperature: number;\n max_response_output_tokens?: number | 'inf';\n speed?: number;\n }>;\n}\n\nexport interface TracingConfig {\n enabled?: boolean;\n}\n\nexport interface InputAudioBufferAppendEvent extends BaseClientEvent {\n type: 'input_audio_buffer.append';\n audio: AudioBase64Bytes;\n}\n\nexport interface InputAudioBufferCommitEvent extends BaseClientEvent {\n type: 'input_audio_buffer.commit';\n}\n\nexport interface InputAudioBufferClearEvent extends BaseClientEvent {\n type: 'input_audio_buffer.clear';\n}\n\nexport interface UserItemCreate {\n id: string;\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItemCreate {\n id: string;\n type: 'message';\n role: 'assistant';\n content: TextContent[];\n}\n\nexport interface SystemItemCreate {\n id: string;\n type: 'message';\n role: 'system';\n content: InputTextContent[];\n}\n\nexport interface FunctionCallOutputItemCreate {\n id: string;\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ConversationItemCreateContent =\n | UserItemCreate\n | AssistantItemCreate\n | SystemItemCreate\n | FunctionCallOutputItemCreate;\n\nexport interface ConversationItemCreateEvent extends BaseClientEvent {\n type: 'conversation.item.create';\n previous_item_id?: string;\n item: ConversationItemCreateContent;\n}\n\nexport interface ConversationItemTruncateEvent extends BaseClientEvent {\n type: 'conversation.item.truncate';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeleteEvent extends BaseClientEvent {\n type: 'conversation.item.delete';\n item_id: string;\n}\n\nexport interface ResponseCreateEvent extends BaseClientEvent {\n type: 'response.create';\n response?: Partial<{\n modalities: Modality[];\n instructions: string;\n voice: Voice;\n output_audio_format: LegacyAudioFormat;\n tools?: Tool[];\n tool_choice: ToolChoice;\n temperature: number;\n max_output_tokens: number | 'inf';\n metadata?: Record<string, string>;\n }>;\n}\n\nexport interface ResponseCancelEvent extends BaseClientEvent {\n type: 'response.cancel';\n}\n\nexport type ClientEvent =\n | SessionUpdateEvent\n | InputAudioBufferAppendEvent\n | InputAudioBufferCommitEvent\n | InputAudioBufferClearEvent\n | ConversationItemCreateEvent\n | ConversationItemTruncateEvent\n | ConversationItemDeleteEvent\n | ResponseCreateEvent\n | ResponseCancelEvent;\n\ninterface BaseServerEvent {\n event_id: string;\n type: ServerEventType;\n}\n\nexport interface ErrorEvent extends BaseServerEvent {\n type: 'error';\n error: {\n type: 'invalid_request_error' | 'server_error' | string;\n code?: string;\n message: string;\n param: string;\n event_id: string;\n };\n}\n\nexport interface SessionCreatedEvent extends BaseServerEvent {\n type: 'session.created';\n session: SessionResource;\n}\n\nexport interface SessionUpdatedEvent extends BaseServerEvent {\n type: 'session.updated';\n session: SessionResource;\n}\n\nexport interface ConversationCreatedEvent extends BaseServerEvent {\n type: 'conversation.created';\n conversation: ConversationResource;\n}\n\nexport interface InputAudioBufferCommittedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.committed';\n item_id: string;\n}\n\nexport interface InputAudioBufferClearedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.cleared';\n}\n\nexport interface InputAudioBufferSpeechStartedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_started';\n audio_start_ms: number;\n item_id: string;\n}\n\nexport interface InputAudioBufferSpeechStoppedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_stopped';\n audio_end_ms: number;\n item_id: string;\n}\n\nexport interface ConversationItemCreatedEvent extends BaseServerEvent {\n type: 'conversation.item.created';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemAddedEvent extends BaseServerEvent {\n type: 'conversation.item.added';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemInputAudioTranscriptionCompletedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.completed';\n item_id: string;\n content_index: number;\n transcript: string;\n}\n\nexport interface ConversationItemInputAudioTranscriptionFailedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.failed';\n item_id: string;\n content_index: number;\n error: {\n type: string;\n code?: string;\n message: string;\n param: null;\n };\n}\n\nexport interface ConversationItemTruncatedEvent extends BaseServerEvent {\n type: 'conversation.item.truncated';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeletedEvent extends BaseServerEvent {\n type: 'conversation.item.deleted';\n item_id: string;\n}\n\nexport interface ResponseCreatedEvent extends BaseServerEvent {\n type: 'response.created';\n response: ResponseResource;\n}\n\nexport interface ResponseDoneEvent extends BaseServerEvent {\n type: 'response.done';\n response: ResponseResource;\n}\n\nexport interface ResponseOutputItemAddedEvent extends BaseServerEvent {\n type: 'response.output_item.added';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseOutputItemDoneEvent extends BaseServerEvent {\n type: 'response.output_item.done';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseContentPartAddedEvent extends BaseServerEvent {\n type: 'response.content_part.added';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseContentPartDoneEvent extends BaseServerEvent {\n type: 'response.content_part.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseTextDeltaEvent extends BaseServerEvent {\n type: 'response.text.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseTextDoneEvent extends BaseServerEvent {\n type: 'response.text.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n text: string;\n}\n\nexport interface ResponseAudioTranscriptDeltaEvent extends BaseServerEvent {\n type: 'response.audio_transcript.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseAudioTranscriptDoneEvent extends BaseServerEvent {\n type: 'response.audio_transcript.done';\n response_id: string;\n output_index: number;\n content_index: number;\n transcript: string;\n}\n\nexport interface ResponseAudioDeltaEvent extends BaseServerEvent {\n type: 'response.audio.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: AudioBase64Bytes;\n}\n\nexport interface ResponseAudioDoneEvent extends BaseServerEvent {\n type: 'response.audio.done';\n response_id: string;\n output_index: number;\n content_index: number;\n}\n\nexport interface ResponseFunctionCallArgumentsDeltaEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.delta';\n response_id: string;\n output_index: number;\n delta: string;\n}\n\nexport interface ResponseFunctionCallArgumentsDoneEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.done';\n response_id: string;\n output_index: number;\n arguments: string;\n}\n\nexport interface RateLimitsUpdatedEvent extends BaseServerEvent {\n type: 'rate_limits.updated';\n rate_limits: {\n name: 'requests' | 'tokens' | 'input_tokens' | 'output_tokens' | string;\n limit: number;\n remaining: number;\n reset_seconds: number;\n }[];\n}\n\nexport type ServerEvent =\n | ErrorEvent\n | SessionCreatedEvent\n | SessionUpdatedEvent\n | ConversationCreatedEvent\n | InputAudioBufferCommittedEvent\n | InputAudioBufferClearedEvent\n | InputAudioBufferSpeechStartedEvent\n | InputAudioBufferSpeechStoppedEvent\n | ConversationItemCreatedEvent\n | ConversationItemAddedEvent // GA: renamed from conversation.item.created\n | ConversationItemInputAudioTranscriptionCompletedEvent\n | ConversationItemInputAudioTranscriptionFailedEvent\n | ConversationItemTruncatedEvent\n | ConversationItemDeletedEvent\n | ResponseCreatedEvent\n | ResponseDoneEvent\n | ResponseOutputItemAddedEvent\n | ResponseOutputItemDoneEvent\n | ResponseContentPartAddedEvent\n | ResponseContentPartDoneEvent\n | ResponseTextDeltaEvent\n | ResponseTextDoneEvent\n | ResponseAudioTranscriptDeltaEvent\n | ResponseAudioTranscriptDoneEvent\n | ResponseAudioDeltaEvent\n | ResponseAudioDoneEvent\n | ResponseFunctionCallArgumentsDeltaEvent\n | ResponseFunctionCallArgumentsDoneEvent\n | RateLimitsUpdatedEvent;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAEvB,MAAM,WAAW;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/realtime/api_proto.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport const SAMPLE_RATE = 24000;\nexport const NUM_CHANNELS = 1;\nexport const IN_FRAME_SIZE = 2400; // 100ms\nexport const OUT_FRAME_SIZE = 1200; // 50ms\n\nexport const BASE_URL = 'wss://api.openai.com/v1';\n\nexport type Model = 'gpt-4o-realtime-preview-2024-10-01' | string; // Open-ended, for future models\nexport type Voice =\n | 'alloy'\n | 'shimmer'\n | 'echo'\n | 'ash'\n | 'ballad'\n | 'coral'\n | 'sage'\n | 'verse'\n | string;\n\n/** @deprecated Use LegacyAudioFormat for Beta API string format or AudioFormat for GA API object format */\nexport type LegacyAudioFormat = 'pcm16'; // TODO: 'g711-ulaw' | 'g711-alaw' (Beta format)\nexport type Role = 'system' | 'assistant' | 'user' | 'tool';\nexport type GenerationFinishedReason = 'stop' | 'max_tokens' | 'content_filter' | 'interrupt';\nexport type InputTranscriptionModel = 'whisper-1' | string; // Open-ended, for future models\nexport type Modality = 'text' | 'audio';\nexport type ToolChoice = 'auto' | 'none' | 'required' | string;\nexport type State = 'initializing' | 'listening' | 'thinking' | 'speaking' | string;\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'incomplete'\n | 'cancelled'\n | 'failed'\n | string;\nexport type ClientEventType =\n | 'session.update'\n | 'input_audio_buffer.append'\n | 'input_audio_buffer.commit'\n | 'input_audio_buffer.clear'\n | 'conversation.item.create'\n | 'conversation.item.truncate'\n | 'conversation.item.delete'\n | 'response.create'\n | 'response.cancel';\n\nexport type ServerEventType =\n | 'error'\n | 'session.created'\n | 'session.updated'\n | 'conversation.created'\n | 'input_audio_buffer.committed'\n | 'input_audio_buffer.cleared'\n | 'input_audio_buffer.speech_started'\n | 'input_audio_buffer.speech_stopped'\n | 'conversation.item.added' // GA: renamed from conversation.item.created\n | 'conversation.item.created' // Beta: kept for backward compatibility\n | 'conversation.item.input_audio_transcription.completed'\n | 'conversation.item.input_audio_transcription.failed'\n | 'conversation.item.truncated'\n | 'conversation.item.deleted'\n | 'response.created'\n | 'response.done'\n | 'response.output_item.added'\n | 'response.output_item.done'\n | 'response.content_part.added'\n | 'response.content_part.done'\n | 'response.output_text.delta' // GA: renamed from response.text.delta\n | 'response.output_text.done' // GA: renamed from response.text.done\n | 'response.text.delta' // Beta: kept for backward compatibility\n | 'response.text.done' // Beta: kept for backward compatibility\n | 'response.output_audio_transcript.delta' // GA: renamed from response.audio_transcript.delta\n | 'response.output_audio_transcript.done' // GA: renamed from response.audio_transcript.done\n | 'response.audio_transcript.delta' // Beta: kept for backward compatibility\n | 'response.audio_transcript.done' // Beta: kept for backward compatibility\n | 'response.output_audio.delta' // GA: renamed from response.audio.delta\n | 'response.output_audio.done' // GA: renamed from response.audio.done\n | 'response.audio.delta' // Beta: kept for backward compatibility\n | 'response.audio.done' // Beta: kept for backward compatibility\n | 'response.function_call_arguments.delta'\n | 'response.function_call_arguments.done'\n | 'rate_limits.updated';\n\nexport type AudioBase64Bytes = string;\n\nexport interface Tool {\n type: 'function';\n name: string;\n description?: string;\n parameters: {\n type: 'object';\n properties: {\n [prop: string]: {\n [prop: string]: any;\n };\n };\n required: string[];\n };\n}\n\nexport type TurnDetectionType =\n | {\n type: 'semantic_vad';\n eagerness?: 'auto' | 'low' | 'medium' | 'high'; // default: auto\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n }\n | {\n type: 'server_vad';\n threshold?: number; // 0.0 to 1.0, default: 0.5\n prefix_padding_ms?: number; // default: 300\n silence_duration_ms?: number; // default: 200\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n };\n\nexport type InputAudioTranscription = {\n model: InputTranscriptionModel;\n language?: string;\n prompt?: string;\n};\n\nexport type NoiseReductionType = 'near_field' | 'far_field';\n\nexport interface NoiseReduction {\n type: NoiseReductionType;\n}\n\nexport interface AudioFormat {\n type: 'audio/pcm';\n rate: number;\n}\n\nexport interface RealtimeAudioConfigInput {\n format?: AudioFormat;\n noise_reduction?: NoiseReduction | null;\n transcription?: InputAudioTranscription | null;\n turn_detection?: TurnDetectionType | null;\n}\n\nexport interface RealtimeAudioConfigOutput {\n format?: AudioFormat;\n speed?: number;\n voice?: Voice;\n}\n\nexport interface RealtimeAudioConfig {\n input?: RealtimeAudioConfigInput;\n output?: RealtimeAudioConfigOutput;\n}\n\nexport interface InputTextContent {\n type: 'input_text';\n text: string;\n}\n\nexport interface InputAudioContent {\n type: 'input_audio';\n audio: AudioBase64Bytes;\n}\n\nexport interface TextContent {\n type: 'text';\n text: string;\n}\n\nexport interface OutputTextContent {\n type: 'output_text';\n text: string;\n}\n\nexport interface AudioContent {\n type: 'audio';\n audio: AudioBase64Bytes;\n transcript: string;\n}\n\nexport type Content =\n | InputTextContent\n | InputAudioContent\n | TextContent\n | OutputTextContent\n | AudioContent;\nexport type ContentPart = {\n type: 'text' | 'audio' | 'output_text' | 'output_audio'; // GA: output_text/output_audio\n audio?: AudioBase64Bytes;\n transcript?: string;\n text?: string; // GA: text field for output_text\n};\n\nexport interface BaseItem {\n id: string;\n object: 'realtime.item';\n type: string;\n}\n\nexport interface SystemItem extends BaseItem {\n type: 'message';\n role: 'system';\n content: InputTextContent;\n}\n\nexport interface UserItem extends BaseItem {\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItem extends BaseItem {\n type: 'message';\n role: 'assistant';\n content: (TextContent | OutputTextContent | AudioContent)[];\n}\n\nexport interface FunctionCallItem extends BaseItem {\n type: 'function_call';\n call_id: string;\n name: string;\n arguments: string;\n}\n\nexport interface FunctionCallOutputItem extends BaseItem {\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ItemResource =\n | SystemItem\n | UserItem\n | AssistantItem\n | FunctionCallItem\n | FunctionCallOutputItem;\n\n// Session Resource\nexport interface SessionResource {\n id: string;\n object: 'realtime.session';\n model: string;\n modalities: Modality[]; // default: [\"text\", \"audio\"]\n instructions: string;\n voice: Voice; // default: \"alloy\"\n input_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n output_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n tools: Tool[];\n tool_choice: ToolChoice; // default: \"auto\"\n temperature: number; // default: 0.8\n max_response_output_tokens: number | 'inf';\n expires_at: number;\n}\n\n// Conversation Resource\nexport interface ConversationResource {\n id: string;\n object: 'realtime.conversation';\n}\n\nexport type ResponseStatusDetails =\n | {\n type: 'incomplete';\n reason: 'max_output_tokens' | 'content_filter' | string;\n }\n | {\n type: 'failed';\n error?: {\n code: 'server_error' | 'rate_limit_exceeded' | string;\n message: string;\n };\n }\n | {\n type: 'cancelled';\n reason: 'turn_detected' | 'client_cancelled' | string;\n };\n\nexport interface ModelUsage {\n total_tokens: number;\n input_tokens: number;\n output_tokens: number;\n input_token_details: {\n text_tokens: number;\n audio_tokens: number;\n cached_tokens: number;\n cached_tokens_details: {\n text_tokens: number;\n audio_tokens: number;\n image_tokens: number;\n };\n };\n output_token_details: {\n text_tokens: number;\n audio_tokens: number;\n };\n}\n\nexport interface ResponseResource {\n id: string;\n object: 'realtime.response';\n status: ResponseStatus;\n status_details: ResponseStatusDetails;\n output: ItemResource[];\n usage?: ModelUsage;\n metadata?: Record<string, string>;\n}\n\n// Client Events\ninterface BaseClientEvent {\n event_id?: string;\n type: ClientEventType;\n}\n\nexport interface SessionUpdateEvent extends BaseClientEvent {\n type: 'session.update';\n session: Partial<{\n // GA fields\n type?: 'realtime'; // GA: session type\n output_modalities?: Modality[]; // GA: renamed from modalities\n audio?: RealtimeAudioConfig; // GA: nested audio config\n max_output_tokens?: number | 'inf'; // GA: renamed from max_response_output_tokens\n tracing?: TracingConfig | null; // GA: tracing config\n // Common fields\n model: Model;\n instructions: string;\n tools: Tool[];\n tool_choice: ToolChoice;\n // Beta fields (kept for backward compatibility)\n modalities: Modality[];\n voice: Voice;\n input_audio_format: LegacyAudioFormat;\n output_audio_format: LegacyAudioFormat;\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n temperature: number;\n max_response_output_tokens?: number | 'inf';\n speed?: number;\n }>;\n}\n\nexport interface TracingConfig {\n enabled?: boolean;\n}\n\nexport interface InputAudioBufferAppendEvent extends BaseClientEvent {\n type: 'input_audio_buffer.append';\n audio: AudioBase64Bytes;\n}\n\nexport interface InputAudioBufferCommitEvent extends BaseClientEvent {\n type: 'input_audio_buffer.commit';\n}\n\nexport interface InputAudioBufferClearEvent extends BaseClientEvent {\n type: 'input_audio_buffer.clear';\n}\n\nexport interface UserItemCreate {\n id: string;\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItemCreate {\n id: string;\n type: 'message';\n role: 'assistant';\n content: TextContent[];\n}\n\nexport interface SystemItemCreate {\n id: string;\n type: 'message';\n role: 'system';\n content: InputTextContent[];\n}\n\nexport interface FunctionCallOutputItemCreate {\n id: string;\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ConversationItemCreateContent =\n | UserItemCreate\n | AssistantItemCreate\n | SystemItemCreate\n | FunctionCallOutputItemCreate;\n\nexport interface ConversationItemCreateEvent extends BaseClientEvent {\n type: 'conversation.item.create';\n previous_item_id?: string;\n item: ConversationItemCreateContent;\n}\n\nexport interface ConversationItemTruncateEvent extends BaseClientEvent {\n type: 'conversation.item.truncate';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeleteEvent extends BaseClientEvent {\n type: 'conversation.item.delete';\n item_id: string;\n}\n\nexport interface ResponseCreateEvent extends BaseClientEvent {\n type: 'response.create';\n response?: Partial<{\n modalities: Modality[];\n instructions: string;\n voice: Voice;\n output_audio_format: LegacyAudioFormat;\n tools?: Tool[];\n tool_choice: ToolChoice;\n temperature: number;\n max_output_tokens: number | 'inf';\n metadata?: Record<string, string>;\n }>;\n}\n\nexport interface ResponseCancelEvent extends BaseClientEvent {\n type: 'response.cancel';\n}\n\nexport type ClientEvent =\n | SessionUpdateEvent\n | InputAudioBufferAppendEvent\n | InputAudioBufferCommitEvent\n | InputAudioBufferClearEvent\n | ConversationItemCreateEvent\n | ConversationItemTruncateEvent\n | ConversationItemDeleteEvent\n | ResponseCreateEvent\n | ResponseCancelEvent;\n\ninterface BaseServerEvent {\n event_id: string;\n type: ServerEventType;\n}\n\nexport interface ErrorEvent extends BaseServerEvent {\n type: 'error';\n error: {\n type: 'invalid_request_error' | 'server_error' | string;\n code?: string;\n message: string;\n param: string;\n event_id: string;\n };\n}\n\nexport interface SessionCreatedEvent extends BaseServerEvent {\n type: 'session.created';\n session: SessionResource;\n}\n\nexport interface SessionUpdatedEvent extends BaseServerEvent {\n type: 'session.updated';\n session: SessionResource;\n}\n\nexport interface ConversationCreatedEvent extends BaseServerEvent {\n type: 'conversation.created';\n conversation: ConversationResource;\n}\n\nexport interface InputAudioBufferCommittedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.committed';\n item_id: string;\n}\n\nexport interface InputAudioBufferClearedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.cleared';\n}\n\nexport interface InputAudioBufferSpeechStartedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_started';\n audio_start_ms: number;\n item_id: string;\n}\n\nexport interface InputAudioBufferSpeechStoppedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_stopped';\n audio_end_ms: number;\n item_id: string;\n}\n\nexport interface ConversationItemCreatedEvent extends BaseServerEvent {\n type: 'conversation.item.created';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemAddedEvent extends BaseServerEvent {\n type: 'conversation.item.added';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemInputAudioTranscriptionCompletedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.completed';\n item_id: string;\n content_index: number;\n transcript: string;\n}\n\nexport interface ConversationItemInputAudioTranscriptionFailedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.failed';\n item_id: string;\n content_index: number;\n error: {\n type: string;\n code?: string;\n message: string;\n param: null;\n };\n}\n\nexport interface ConversationItemTruncatedEvent extends BaseServerEvent {\n type: 'conversation.item.truncated';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeletedEvent extends BaseServerEvent {\n type: 'conversation.item.deleted';\n item_id: string;\n}\n\nexport interface ResponseCreatedEvent extends BaseServerEvent {\n type: 'response.created';\n response: ResponseResource;\n}\n\nexport interface ResponseDoneEvent extends BaseServerEvent {\n type: 'response.done';\n response: ResponseResource;\n}\n\nexport interface ResponseOutputItemAddedEvent extends BaseServerEvent {\n type: 'response.output_item.added';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseOutputItemDoneEvent extends BaseServerEvent {\n type: 'response.output_item.done';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseContentPartAddedEvent extends BaseServerEvent {\n type: 'response.content_part.added';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseContentPartDoneEvent extends BaseServerEvent {\n type: 'response.content_part.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseTextDeltaEvent extends BaseServerEvent {\n type: 'response.text.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseTextDoneEvent extends BaseServerEvent {\n type: 'response.text.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n text: string;\n}\n\nexport interface ResponseAudioTranscriptDeltaEvent extends BaseServerEvent {\n type: 'response.audio_transcript.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseAudioTranscriptDoneEvent extends BaseServerEvent {\n type: 'response.audio_transcript.done';\n response_id: string;\n output_index: number;\n content_index: number;\n transcript: string;\n}\n\nexport interface ResponseAudioDeltaEvent extends BaseServerEvent {\n type: 'response.audio.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: AudioBase64Bytes;\n}\n\nexport interface ResponseAudioDoneEvent extends BaseServerEvent {\n type: 'response.audio.done';\n response_id: string;\n output_index: number;\n content_index: number;\n}\n\nexport interface ResponseFunctionCallArgumentsDeltaEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.delta';\n response_id: string;\n output_index: number;\n delta: string;\n}\n\nexport interface ResponseFunctionCallArgumentsDoneEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.done';\n response_id: string;\n output_index: number;\n arguments: string;\n}\n\nexport interface RateLimitsUpdatedEvent extends BaseServerEvent {\n type: 'rate_limits.updated';\n rate_limits: {\n name: 'requests' | 'tokens' | 'input_tokens' | 'output_tokens' | string;\n limit: number;\n remaining: number;\n reset_seconds: number;\n }[];\n}\n\nexport type ServerEvent =\n | ErrorEvent\n | SessionCreatedEvent\n | SessionUpdatedEvent\n | ConversationCreatedEvent\n | InputAudioBufferCommittedEvent\n | InputAudioBufferClearedEvent\n | InputAudioBufferSpeechStartedEvent\n | InputAudioBufferSpeechStoppedEvent\n | ConversationItemCreatedEvent\n | ConversationItemAddedEvent // GA: renamed from conversation.item.created\n | ConversationItemInputAudioTranscriptionCompletedEvent\n | ConversationItemInputAudioTranscriptionFailedEvent\n | ConversationItemTruncatedEvent\n | ConversationItemDeletedEvent\n | ResponseCreatedEvent\n | ResponseDoneEvent\n | ResponseOutputItemAddedEvent\n | ResponseOutputItemDoneEvent\n | ResponseContentPartAddedEvent\n | ResponseContentPartDoneEvent\n | ResponseTextDeltaEvent\n | ResponseTextDoneEvent\n | ResponseAudioTranscriptDeltaEvent\n | ResponseAudioTranscriptDoneEvent\n | ResponseAudioDeltaEvent\n | ResponseAudioDoneEvent\n | ResponseFunctionCallArgumentsDeltaEvent\n | ResponseFunctionCallArgumentsDoneEvent\n | RateLimitsUpdatedEvent;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAEvB,MAAM,WAAW;","names":[]}
|
|
@@ -84,12 +84,16 @@ export interface TextContent {
|
|
|
84
84
|
type: 'text';
|
|
85
85
|
text: string;
|
|
86
86
|
}
|
|
87
|
+
export interface OutputTextContent {
|
|
88
|
+
type: 'output_text';
|
|
89
|
+
text: string;
|
|
90
|
+
}
|
|
87
91
|
export interface AudioContent {
|
|
88
92
|
type: 'audio';
|
|
89
93
|
audio: AudioBase64Bytes;
|
|
90
94
|
transcript: string;
|
|
91
95
|
}
|
|
92
|
-
export type Content = InputTextContent | InputAudioContent | TextContent | AudioContent;
|
|
96
|
+
export type Content = InputTextContent | InputAudioContent | TextContent | OutputTextContent | AudioContent;
|
|
93
97
|
export type ContentPart = {
|
|
94
98
|
type: 'text' | 'audio' | 'output_text' | 'output_audio';
|
|
95
99
|
audio?: AudioBase64Bytes;
|
|
@@ -114,7 +118,7 @@ export interface UserItem extends BaseItem {
|
|
|
114
118
|
export interface AssistantItem extends BaseItem {
|
|
115
119
|
type: 'message';
|
|
116
120
|
role: 'assistant';
|
|
117
|
-
content: (TextContent | AudioContent)[];
|
|
121
|
+
content: (TextContent | OutputTextContent | AudioContent)[];
|
|
118
122
|
}
|
|
119
123
|
export interface FunctionCallItem extends BaseItem {
|
|
120
124
|
type: 'function_call';
|
|
@@ -84,12 +84,16 @@ export interface TextContent {
|
|
|
84
84
|
type: 'text';
|
|
85
85
|
text: string;
|
|
86
86
|
}
|
|
87
|
+
export interface OutputTextContent {
|
|
88
|
+
type: 'output_text';
|
|
89
|
+
text: string;
|
|
90
|
+
}
|
|
87
91
|
export interface AudioContent {
|
|
88
92
|
type: 'audio';
|
|
89
93
|
audio: AudioBase64Bytes;
|
|
90
94
|
transcript: string;
|
|
91
95
|
}
|
|
92
|
-
export type Content = InputTextContent | InputAudioContent | TextContent | AudioContent;
|
|
96
|
+
export type Content = InputTextContent | InputAudioContent | TextContent | OutputTextContent | AudioContent;
|
|
93
97
|
export type ContentPart = {
|
|
94
98
|
type: 'text' | 'audio' | 'output_text' | 'output_audio';
|
|
95
99
|
audio?: AudioBase64Bytes;
|
|
@@ -114,7 +118,7 @@ export interface UserItem extends BaseItem {
|
|
|
114
118
|
export interface AssistantItem extends BaseItem {
|
|
115
119
|
type: 'message';
|
|
116
120
|
role: 'assistant';
|
|
117
|
-
content: (TextContent | AudioContent)[];
|
|
121
|
+
content: (TextContent | OutputTextContent | AudioContent)[];
|
|
118
122
|
}
|
|
119
123
|
export interface FunctionCallItem extends BaseItem {
|
|
120
124
|
type: 'function_call';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_proto.d.ts","sourceRoot":"","sources":["../../src/realtime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,UAAU,GACV,mBAAmB,GACnB,mBAAmB,GACnB,wBAAwB,GACxB,8BAA8B,GAC9B,4BAA4B,GAC5B,kCAAkC,GAClC,kCAAkC,GAClC,4BAA4B,GAC5B,0BAA0B,GAC1B,qDAAqD,GACrD,kDAAkD,GAClD,8BAA8B,GAC9B,4BAA4B,GAC5B,oBAAoB,GACpB,iBAAiB,GACjB,4BAA4B,GAC5B,2BAA2B,GAC3B,6BAA6B,GAC7B,4BAA4B,GAC5B,sBAAsB,GACtB,qBAAqB,GACrB,iCAAiC,GACjC,gCAAgC,GAChC,uBAAuB,GACvB,sBAAsB,GACtB,uCAAuC,GACvC,sCAAsC,GACtC,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/realtime/api_proto.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport const SAMPLE_RATE = 24000;\nexport const NUM_CHANNELS = 1;\nexport const IN_FRAME_SIZE = 2400; // 100ms\nexport const OUT_FRAME_SIZE = 1200; // 50ms\n\nexport const BASE_URL = 'wss://api.openai.com/v1';\n\nexport type Model = 'gpt-4o-realtime-preview-2024-10-01' | string; // Open-ended, for future models\nexport type Voice =\n | 'alloy'\n | 'shimmer'\n | 'echo'\n | 'ash'\n | 'ballad'\n | 'coral'\n | 'sage'\n | 'verse'\n | string;\n\n/** @deprecated Use LegacyAudioFormat for Beta API string format or AudioFormat for GA API object format */\nexport type LegacyAudioFormat = 'pcm16'; // TODO: 'g711-ulaw' | 'g711-alaw' (Beta format)\nexport type Role = 'system' | 'assistant' | 'user' | 'tool';\nexport type GenerationFinishedReason = 'stop' | 'max_tokens' | 'content_filter' | 'interrupt';\nexport type InputTranscriptionModel = 'whisper-1' | string; // Open-ended, for future models\nexport type Modality = 'text' | 'audio';\nexport type ToolChoice = 'auto' | 'none' | 'required' | string;\nexport type State = 'initializing' | 'listening' | 'thinking' | 'speaking' | string;\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'incomplete'\n | 'cancelled'\n | 'failed'\n | string;\nexport type ClientEventType =\n | 'session.update'\n | 'input_audio_buffer.append'\n | 'input_audio_buffer.commit'\n | 'input_audio_buffer.clear'\n | 'conversation.item.create'\n | 'conversation.item.truncate'\n | 'conversation.item.delete'\n | 'response.create'\n | 'response.cancel';\n\nexport type ServerEventType =\n | 'error'\n | 'session.created'\n | 'session.updated'\n | 'conversation.created'\n | 'input_audio_buffer.committed'\n | 'input_audio_buffer.cleared'\n | 'input_audio_buffer.speech_started'\n | 'input_audio_buffer.speech_stopped'\n | 'conversation.item.added' // GA: renamed from conversation.item.created\n | 'conversation.item.created' // Beta: kept for backward compatibility\n | 'conversation.item.input_audio_transcription.completed'\n | 'conversation.item.input_audio_transcription.failed'\n | 'conversation.item.truncated'\n | 'conversation.item.deleted'\n | 'response.created'\n | 'response.done'\n | 'response.output_item.added'\n | 'response.output_item.done'\n | 'response.content_part.added'\n | 'response.content_part.done'\n | 'response.output_text.delta' // GA: renamed from response.text.delta\n | 'response.output_text.done' // GA: renamed from response.text.done\n | 'response.text.delta' // Beta: kept for backward compatibility\n | 'response.text.done' // Beta: kept for backward compatibility\n | 'response.output_audio_transcript.delta' // GA: renamed from response.audio_transcript.delta\n | 'response.output_audio_transcript.done' // GA: renamed from response.audio_transcript.done\n | 'response.audio_transcript.delta' // Beta: kept for backward compatibility\n | 'response.audio_transcript.done' // Beta: kept for backward compatibility\n | 'response.output_audio.delta' // GA: renamed from response.audio.delta\n | 'response.output_audio.done' // GA: renamed from response.audio.done\n | 'response.audio.delta' // Beta: kept for backward compatibility\n | 'response.audio.done' // Beta: kept for backward compatibility\n | 'response.function_call_arguments.delta'\n | 'response.function_call_arguments.done'\n | 'rate_limits.updated';\n\nexport type AudioBase64Bytes = string;\n\nexport interface Tool {\n type: 'function';\n name: string;\n description?: string;\n parameters: {\n type: 'object';\n properties: {\n [prop: string]: {\n [prop: string]: any;\n };\n };\n required: string[];\n };\n}\n\nexport type TurnDetectionType =\n | {\n type: 'semantic_vad';\n eagerness?: 'auto' | 'low' | 'medium' | 'high'; // default: auto\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n }\n | {\n type: 'server_vad';\n threshold?: number; // 0.0 to 1.0, default: 0.5\n prefix_padding_ms?: number; // default: 300\n silence_duration_ms?: number; // default: 200\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n };\n\nexport type InputAudioTranscription = {\n model: InputTranscriptionModel;\n language?: string;\n prompt?: string;\n};\n\nexport type NoiseReductionType = 'near_field' | 'far_field';\n\nexport interface NoiseReduction {\n type: NoiseReductionType;\n}\n\nexport interface AudioFormat {\n type: 'audio/pcm';\n rate: number;\n}\n\nexport interface RealtimeAudioConfigInput {\n format?: AudioFormat;\n noise_reduction?: NoiseReduction | null;\n transcription?: InputAudioTranscription | null;\n turn_detection?: TurnDetectionType | null;\n}\n\nexport interface RealtimeAudioConfigOutput {\n format?: AudioFormat;\n speed?: number;\n voice?: Voice;\n}\n\nexport interface RealtimeAudioConfig {\n input?: RealtimeAudioConfigInput;\n output?: RealtimeAudioConfigOutput;\n}\n\nexport interface InputTextContent {\n type: 'input_text';\n text: string;\n}\n\nexport interface InputAudioContent {\n type: 'input_audio';\n audio: AudioBase64Bytes;\n}\n\nexport interface TextContent {\n type: 'text';\n text: string;\n}\n\nexport interface AudioContent {\n type: 'audio';\n audio: AudioBase64Bytes;\n transcript: string;\n}\n\nexport type Content = InputTextContent | InputAudioContent | TextContent | AudioContent;\nexport type ContentPart = {\n type: 'text' | 'audio' | 'output_text' | 'output_audio'; // GA: output_text/output_audio\n audio?: AudioBase64Bytes;\n transcript?: string;\n text?: string; // GA: text field for output_text\n};\n\nexport interface BaseItem {\n id: string;\n object: 'realtime.item';\n type: string;\n}\n\nexport interface SystemItem extends BaseItem {\n type: 'message';\n role: 'system';\n content: InputTextContent;\n}\n\nexport interface UserItem extends BaseItem {\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItem extends BaseItem {\n type: 'message';\n role: 'assistant';\n content: (TextContent | AudioContent)[];\n}\n\nexport interface FunctionCallItem extends BaseItem {\n type: 'function_call';\n call_id: string;\n name: string;\n arguments: string;\n}\n\nexport interface FunctionCallOutputItem extends BaseItem {\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ItemResource =\n | SystemItem\n | UserItem\n | AssistantItem\n | FunctionCallItem\n | FunctionCallOutputItem;\n\n// Session Resource\nexport interface SessionResource {\n id: string;\n object: 'realtime.session';\n model: string;\n modalities: Modality[]; // default: [\"text\", \"audio\"]\n instructions: string;\n voice: Voice; // default: \"alloy\"\n input_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n output_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n tools: Tool[];\n tool_choice: ToolChoice; // default: \"auto\"\n temperature: number; // default: 0.8\n max_response_output_tokens: number | 'inf';\n expires_at: number;\n}\n\n// Conversation Resource\nexport interface ConversationResource {\n id: string;\n object: 'realtime.conversation';\n}\n\nexport type ResponseStatusDetails =\n | {\n type: 'incomplete';\n reason: 'max_output_tokens' | 'content_filter' | string;\n }\n | {\n type: 'failed';\n error?: {\n code: 'server_error' | 'rate_limit_exceeded' | string;\n message: string;\n };\n }\n | {\n type: 'cancelled';\n reason: 'turn_detected' | 'client_cancelled' | string;\n };\n\nexport interface ModelUsage {\n total_tokens: number;\n input_tokens: number;\n output_tokens: number;\n input_token_details: {\n text_tokens: number;\n audio_tokens: number;\n cached_tokens: number;\n cached_tokens_details: {\n text_tokens: number;\n audio_tokens: number;\n image_tokens: number;\n };\n };\n output_token_details: {\n text_tokens: number;\n audio_tokens: number;\n };\n}\n\nexport interface ResponseResource {\n id: string;\n object: 'realtime.response';\n status: ResponseStatus;\n status_details: ResponseStatusDetails;\n output: ItemResource[];\n usage?: ModelUsage;\n metadata?: Record<string, string>;\n}\n\n// Client Events\ninterface BaseClientEvent {\n event_id?: string;\n type: ClientEventType;\n}\n\nexport interface SessionUpdateEvent extends BaseClientEvent {\n type: 'session.update';\n session: Partial<{\n // GA fields\n type?: 'realtime'; // GA: session type\n output_modalities?: Modality[]; // GA: renamed from modalities\n audio?: RealtimeAudioConfig; // GA: nested audio config\n max_output_tokens?: number | 'inf'; // GA: renamed from max_response_output_tokens\n tracing?: TracingConfig | null; // GA: tracing config\n // Common fields\n model: Model;\n instructions: string;\n tools: Tool[];\n tool_choice: ToolChoice;\n // Beta fields (kept for backward compatibility)\n modalities: Modality[];\n voice: Voice;\n input_audio_format: LegacyAudioFormat;\n output_audio_format: LegacyAudioFormat;\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n temperature: number;\n max_response_output_tokens?: number | 'inf';\n speed?: number;\n }>;\n}\n\nexport interface TracingConfig {\n enabled?: boolean;\n}\n\nexport interface InputAudioBufferAppendEvent extends BaseClientEvent {\n type: 'input_audio_buffer.append';\n audio: AudioBase64Bytes;\n}\n\nexport interface InputAudioBufferCommitEvent extends BaseClientEvent {\n type: 'input_audio_buffer.commit';\n}\n\nexport interface InputAudioBufferClearEvent extends BaseClientEvent {\n type: 'input_audio_buffer.clear';\n}\n\nexport interface UserItemCreate {\n id: string;\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItemCreate {\n id: string;\n type: 'message';\n role: 'assistant';\n content: TextContent[];\n}\n\nexport interface SystemItemCreate {\n id: string;\n type: 'message';\n role: 'system';\n content: InputTextContent[];\n}\n\nexport interface FunctionCallOutputItemCreate {\n id: string;\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ConversationItemCreateContent =\n | UserItemCreate\n | AssistantItemCreate\n | SystemItemCreate\n | FunctionCallOutputItemCreate;\n\nexport interface ConversationItemCreateEvent extends BaseClientEvent {\n type: 'conversation.item.create';\n previous_item_id?: string;\n item: ConversationItemCreateContent;\n}\n\nexport interface ConversationItemTruncateEvent extends BaseClientEvent {\n type: 'conversation.item.truncate';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeleteEvent extends BaseClientEvent {\n type: 'conversation.item.delete';\n item_id: string;\n}\n\nexport interface ResponseCreateEvent extends BaseClientEvent {\n type: 'response.create';\n response?: Partial<{\n modalities: Modality[];\n instructions: string;\n voice: Voice;\n output_audio_format: LegacyAudioFormat;\n tools?: Tool[];\n tool_choice: ToolChoice;\n temperature: number;\n max_output_tokens: number | 'inf';\n metadata?: Record<string, string>;\n }>;\n}\n\nexport interface ResponseCancelEvent extends BaseClientEvent {\n type: 'response.cancel';\n}\n\nexport type ClientEvent =\n | SessionUpdateEvent\n | InputAudioBufferAppendEvent\n | InputAudioBufferCommitEvent\n | InputAudioBufferClearEvent\n | ConversationItemCreateEvent\n | ConversationItemTruncateEvent\n | ConversationItemDeleteEvent\n | ResponseCreateEvent\n | ResponseCancelEvent;\n\ninterface BaseServerEvent {\n event_id: string;\n type: ServerEventType;\n}\n\nexport interface ErrorEvent extends BaseServerEvent {\n type: 'error';\n error: {\n type: 'invalid_request_error' | 'server_error' | string;\n code?: string;\n message: string;\n param: string;\n event_id: string;\n };\n}\n\nexport interface SessionCreatedEvent extends BaseServerEvent {\n type: 'session.created';\n session: SessionResource;\n}\n\nexport interface SessionUpdatedEvent extends BaseServerEvent {\n type: 'session.updated';\n session: SessionResource;\n}\n\nexport interface ConversationCreatedEvent extends BaseServerEvent {\n type: 'conversation.created';\n conversation: ConversationResource;\n}\n\nexport interface InputAudioBufferCommittedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.committed';\n item_id: string;\n}\n\nexport interface InputAudioBufferClearedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.cleared';\n}\n\nexport interface InputAudioBufferSpeechStartedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_started';\n audio_start_ms: number;\n item_id: string;\n}\n\nexport interface InputAudioBufferSpeechStoppedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_stopped';\n audio_end_ms: number;\n item_id: string;\n}\n\nexport interface ConversationItemCreatedEvent extends BaseServerEvent {\n type: 'conversation.item.created';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemAddedEvent extends BaseServerEvent {\n type: 'conversation.item.added';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemInputAudioTranscriptionCompletedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.completed';\n item_id: string;\n content_index: number;\n transcript: string;\n}\n\nexport interface ConversationItemInputAudioTranscriptionFailedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.failed';\n item_id: string;\n content_index: number;\n error: {\n type: string;\n code?: string;\n message: string;\n param: null;\n };\n}\n\nexport interface ConversationItemTruncatedEvent extends BaseServerEvent {\n type: 'conversation.item.truncated';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeletedEvent extends BaseServerEvent {\n type: 'conversation.item.deleted';\n item_id: string;\n}\n\nexport interface ResponseCreatedEvent extends BaseServerEvent {\n type: 'response.created';\n response: ResponseResource;\n}\n\nexport interface ResponseDoneEvent extends BaseServerEvent {\n type: 'response.done';\n response: ResponseResource;\n}\n\nexport interface ResponseOutputItemAddedEvent extends BaseServerEvent {\n type: 'response.output_item.added';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseOutputItemDoneEvent extends BaseServerEvent {\n type: 'response.output_item.done';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseContentPartAddedEvent extends BaseServerEvent {\n type: 'response.content_part.added';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseContentPartDoneEvent extends BaseServerEvent {\n type: 'response.content_part.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseTextDeltaEvent extends BaseServerEvent {\n type: 'response.text.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseTextDoneEvent extends BaseServerEvent {\n type: 'response.text.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n text: string;\n}\n\nexport interface ResponseAudioTranscriptDeltaEvent extends BaseServerEvent {\n type: 'response.audio_transcript.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseAudioTranscriptDoneEvent extends BaseServerEvent {\n type: 'response.audio_transcript.done';\n response_id: string;\n output_index: number;\n content_index: number;\n transcript: string;\n}\n\nexport interface ResponseAudioDeltaEvent extends BaseServerEvent {\n type: 'response.audio.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: AudioBase64Bytes;\n}\n\nexport interface ResponseAudioDoneEvent extends BaseServerEvent {\n type: 'response.audio.done';\n response_id: string;\n output_index: number;\n content_index: number;\n}\n\nexport interface ResponseFunctionCallArgumentsDeltaEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.delta';\n response_id: string;\n output_index: number;\n delta: string;\n}\n\nexport interface ResponseFunctionCallArgumentsDoneEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.done';\n response_id: string;\n output_index: number;\n arguments: string;\n}\n\nexport interface RateLimitsUpdatedEvent extends BaseServerEvent {\n type: 'rate_limits.updated';\n rate_limits: {\n name: 'requests' | 'tokens' | 'input_tokens' | 'output_tokens' | string;\n limit: number;\n remaining: number;\n reset_seconds: number;\n }[];\n}\n\nexport type ServerEvent =\n | ErrorEvent\n | SessionCreatedEvent\n | SessionUpdatedEvent\n | ConversationCreatedEvent\n | InputAudioBufferCommittedEvent\n | InputAudioBufferClearedEvent\n | InputAudioBufferSpeechStartedEvent\n | InputAudioBufferSpeechStoppedEvent\n | ConversationItemCreatedEvent\n | ConversationItemAddedEvent // GA: renamed from conversation.item.created\n | ConversationItemInputAudioTranscriptionCompletedEvent\n | ConversationItemInputAudioTranscriptionFailedEvent\n | ConversationItemTruncatedEvent\n | ConversationItemDeletedEvent\n | ResponseCreatedEvent\n | ResponseDoneEvent\n | ResponseOutputItemAddedEvent\n | ResponseOutputItemDoneEvent\n | ResponseContentPartAddedEvent\n | ResponseContentPartDoneEvent\n | ResponseTextDeltaEvent\n | ResponseTextDoneEvent\n | ResponseAudioTranscriptDeltaEvent\n | ResponseAudioTranscriptDoneEvent\n | ResponseAudioDeltaEvent\n | ResponseAudioDoneEvent\n | ResponseFunctionCallArgumentsDeltaEvent\n | ResponseFunctionCallArgumentsDoneEvent\n | RateLimitsUpdatedEvent;\n"],"mappings":"AAIO,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAEvB,MAAM,WAAW;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/realtime/api_proto.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport const SAMPLE_RATE = 24000;\nexport const NUM_CHANNELS = 1;\nexport const IN_FRAME_SIZE = 2400; // 100ms\nexport const OUT_FRAME_SIZE = 1200; // 50ms\n\nexport const BASE_URL = 'wss://api.openai.com/v1';\n\nexport type Model = 'gpt-4o-realtime-preview-2024-10-01' | string; // Open-ended, for future models\nexport type Voice =\n | 'alloy'\n | 'shimmer'\n | 'echo'\n | 'ash'\n | 'ballad'\n | 'coral'\n | 'sage'\n | 'verse'\n | string;\n\n/** @deprecated Use LegacyAudioFormat for Beta API string format or AudioFormat for GA API object format */\nexport type LegacyAudioFormat = 'pcm16'; // TODO: 'g711-ulaw' | 'g711-alaw' (Beta format)\nexport type Role = 'system' | 'assistant' | 'user' | 'tool';\nexport type GenerationFinishedReason = 'stop' | 'max_tokens' | 'content_filter' | 'interrupt';\nexport type InputTranscriptionModel = 'whisper-1' | string; // Open-ended, for future models\nexport type Modality = 'text' | 'audio';\nexport type ToolChoice = 'auto' | 'none' | 'required' | string;\nexport type State = 'initializing' | 'listening' | 'thinking' | 'speaking' | string;\nexport type ResponseStatus =\n | 'in_progress'\n | 'completed'\n | 'incomplete'\n | 'cancelled'\n | 'failed'\n | string;\nexport type ClientEventType =\n | 'session.update'\n | 'input_audio_buffer.append'\n | 'input_audio_buffer.commit'\n | 'input_audio_buffer.clear'\n | 'conversation.item.create'\n | 'conversation.item.truncate'\n | 'conversation.item.delete'\n | 'response.create'\n | 'response.cancel';\n\nexport type ServerEventType =\n | 'error'\n | 'session.created'\n | 'session.updated'\n | 'conversation.created'\n | 'input_audio_buffer.committed'\n | 'input_audio_buffer.cleared'\n | 'input_audio_buffer.speech_started'\n | 'input_audio_buffer.speech_stopped'\n | 'conversation.item.added' // GA: renamed from conversation.item.created\n | 'conversation.item.created' // Beta: kept for backward compatibility\n | 'conversation.item.input_audio_transcription.completed'\n | 'conversation.item.input_audio_transcription.failed'\n | 'conversation.item.truncated'\n | 'conversation.item.deleted'\n | 'response.created'\n | 'response.done'\n | 'response.output_item.added'\n | 'response.output_item.done'\n | 'response.content_part.added'\n | 'response.content_part.done'\n | 'response.output_text.delta' // GA: renamed from response.text.delta\n | 'response.output_text.done' // GA: renamed from response.text.done\n | 'response.text.delta' // Beta: kept for backward compatibility\n | 'response.text.done' // Beta: kept for backward compatibility\n | 'response.output_audio_transcript.delta' // GA: renamed from response.audio_transcript.delta\n | 'response.output_audio_transcript.done' // GA: renamed from response.audio_transcript.done\n | 'response.audio_transcript.delta' // Beta: kept for backward compatibility\n | 'response.audio_transcript.done' // Beta: kept for backward compatibility\n | 'response.output_audio.delta' // GA: renamed from response.audio.delta\n | 'response.output_audio.done' // GA: renamed from response.audio.done\n | 'response.audio.delta' // Beta: kept for backward compatibility\n | 'response.audio.done' // Beta: kept for backward compatibility\n | 'response.function_call_arguments.delta'\n | 'response.function_call_arguments.done'\n | 'rate_limits.updated';\n\nexport type AudioBase64Bytes = string;\n\nexport interface Tool {\n type: 'function';\n name: string;\n description?: string;\n parameters: {\n type: 'object';\n properties: {\n [prop: string]: {\n [prop: string]: any;\n };\n };\n required: string[];\n };\n}\n\nexport type TurnDetectionType =\n | {\n type: 'semantic_vad';\n eagerness?: 'auto' | 'low' | 'medium' | 'high'; // default: auto\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n }\n | {\n type: 'server_vad';\n threshold?: number; // 0.0 to 1.0, default: 0.5\n prefix_padding_ms?: number; // default: 300\n silence_duration_ms?: number; // default: 200\n create_response?: boolean; // default: true\n interrupt_response?: boolean; // default: true\n };\n\nexport type InputAudioTranscription = {\n model: InputTranscriptionModel;\n language?: string;\n prompt?: string;\n};\n\nexport type NoiseReductionType = 'near_field' | 'far_field';\n\nexport interface NoiseReduction {\n type: NoiseReductionType;\n}\n\nexport interface AudioFormat {\n type: 'audio/pcm';\n rate: number;\n}\n\nexport interface RealtimeAudioConfigInput {\n format?: AudioFormat;\n noise_reduction?: NoiseReduction | null;\n transcription?: InputAudioTranscription | null;\n turn_detection?: TurnDetectionType | null;\n}\n\nexport interface RealtimeAudioConfigOutput {\n format?: AudioFormat;\n speed?: number;\n voice?: Voice;\n}\n\nexport interface RealtimeAudioConfig {\n input?: RealtimeAudioConfigInput;\n output?: RealtimeAudioConfigOutput;\n}\n\nexport interface InputTextContent {\n type: 'input_text';\n text: string;\n}\n\nexport interface InputAudioContent {\n type: 'input_audio';\n audio: AudioBase64Bytes;\n}\n\nexport interface TextContent {\n type: 'text';\n text: string;\n}\n\nexport interface OutputTextContent {\n type: 'output_text';\n text: string;\n}\n\nexport interface AudioContent {\n type: 'audio';\n audio: AudioBase64Bytes;\n transcript: string;\n}\n\nexport type Content =\n | InputTextContent\n | InputAudioContent\n | TextContent\n | OutputTextContent\n | AudioContent;\nexport type ContentPart = {\n type: 'text' | 'audio' | 'output_text' | 'output_audio'; // GA: output_text/output_audio\n audio?: AudioBase64Bytes;\n transcript?: string;\n text?: string; // GA: text field for output_text\n};\n\nexport interface BaseItem {\n id: string;\n object: 'realtime.item';\n type: string;\n}\n\nexport interface SystemItem extends BaseItem {\n type: 'message';\n role: 'system';\n content: InputTextContent;\n}\n\nexport interface UserItem extends BaseItem {\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItem extends BaseItem {\n type: 'message';\n role: 'assistant';\n content: (TextContent | OutputTextContent | AudioContent)[];\n}\n\nexport interface FunctionCallItem extends BaseItem {\n type: 'function_call';\n call_id: string;\n name: string;\n arguments: string;\n}\n\nexport interface FunctionCallOutputItem extends BaseItem {\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ItemResource =\n | SystemItem\n | UserItem\n | AssistantItem\n | FunctionCallItem\n | FunctionCallOutputItem;\n\n// Session Resource\nexport interface SessionResource {\n id: string;\n object: 'realtime.session';\n model: string;\n modalities: Modality[]; // default: [\"text\", \"audio\"]\n instructions: string;\n voice: Voice; // default: \"alloy\"\n input_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n output_audio_format: LegacyAudioFormat; // default: \"pcm16\"\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n tools: Tool[];\n tool_choice: ToolChoice; // default: \"auto\"\n temperature: number; // default: 0.8\n max_response_output_tokens: number | 'inf';\n expires_at: number;\n}\n\n// Conversation Resource\nexport interface ConversationResource {\n id: string;\n object: 'realtime.conversation';\n}\n\nexport type ResponseStatusDetails =\n | {\n type: 'incomplete';\n reason: 'max_output_tokens' | 'content_filter' | string;\n }\n | {\n type: 'failed';\n error?: {\n code: 'server_error' | 'rate_limit_exceeded' | string;\n message: string;\n };\n }\n | {\n type: 'cancelled';\n reason: 'turn_detected' | 'client_cancelled' | string;\n };\n\nexport interface ModelUsage {\n total_tokens: number;\n input_tokens: number;\n output_tokens: number;\n input_token_details: {\n text_tokens: number;\n audio_tokens: number;\n cached_tokens: number;\n cached_tokens_details: {\n text_tokens: number;\n audio_tokens: number;\n image_tokens: number;\n };\n };\n output_token_details: {\n text_tokens: number;\n audio_tokens: number;\n };\n}\n\nexport interface ResponseResource {\n id: string;\n object: 'realtime.response';\n status: ResponseStatus;\n status_details: ResponseStatusDetails;\n output: ItemResource[];\n usage?: ModelUsage;\n metadata?: Record<string, string>;\n}\n\n// Client Events\ninterface BaseClientEvent {\n event_id?: string;\n type: ClientEventType;\n}\n\nexport interface SessionUpdateEvent extends BaseClientEvent {\n type: 'session.update';\n session: Partial<{\n // GA fields\n type?: 'realtime'; // GA: session type\n output_modalities?: Modality[]; // GA: renamed from modalities\n audio?: RealtimeAudioConfig; // GA: nested audio config\n max_output_tokens?: number | 'inf'; // GA: renamed from max_response_output_tokens\n tracing?: TracingConfig | null; // GA: tracing config\n // Common fields\n model: Model;\n instructions: string;\n tools: Tool[];\n tool_choice: ToolChoice;\n // Beta fields (kept for backward compatibility)\n modalities: Modality[];\n voice: Voice;\n input_audio_format: LegacyAudioFormat;\n output_audio_format: LegacyAudioFormat;\n input_audio_transcription: InputAudioTranscription | null;\n turn_detection: TurnDetectionType | null;\n temperature: number;\n max_response_output_tokens?: number | 'inf';\n speed?: number;\n }>;\n}\n\nexport interface TracingConfig {\n enabled?: boolean;\n}\n\nexport interface InputAudioBufferAppendEvent extends BaseClientEvent {\n type: 'input_audio_buffer.append';\n audio: AudioBase64Bytes;\n}\n\nexport interface InputAudioBufferCommitEvent extends BaseClientEvent {\n type: 'input_audio_buffer.commit';\n}\n\nexport interface InputAudioBufferClearEvent extends BaseClientEvent {\n type: 'input_audio_buffer.clear';\n}\n\nexport interface UserItemCreate {\n id: string;\n type: 'message';\n role: 'user';\n content: (InputTextContent | InputAudioContent)[];\n}\n\nexport interface AssistantItemCreate {\n id: string;\n type: 'message';\n role: 'assistant';\n content: TextContent[];\n}\n\nexport interface SystemItemCreate {\n id: string;\n type: 'message';\n role: 'system';\n content: InputTextContent[];\n}\n\nexport interface FunctionCallOutputItemCreate {\n id: string;\n type: 'function_call_output';\n call_id: string;\n output: string;\n}\n\nexport type ConversationItemCreateContent =\n | UserItemCreate\n | AssistantItemCreate\n | SystemItemCreate\n | FunctionCallOutputItemCreate;\n\nexport interface ConversationItemCreateEvent extends BaseClientEvent {\n type: 'conversation.item.create';\n previous_item_id?: string;\n item: ConversationItemCreateContent;\n}\n\nexport interface ConversationItemTruncateEvent extends BaseClientEvent {\n type: 'conversation.item.truncate';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeleteEvent extends BaseClientEvent {\n type: 'conversation.item.delete';\n item_id: string;\n}\n\nexport interface ResponseCreateEvent extends BaseClientEvent {\n type: 'response.create';\n response?: Partial<{\n modalities: Modality[];\n instructions: string;\n voice: Voice;\n output_audio_format: LegacyAudioFormat;\n tools?: Tool[];\n tool_choice: ToolChoice;\n temperature: number;\n max_output_tokens: number | 'inf';\n metadata?: Record<string, string>;\n }>;\n}\n\nexport interface ResponseCancelEvent extends BaseClientEvent {\n type: 'response.cancel';\n}\n\nexport type ClientEvent =\n | SessionUpdateEvent\n | InputAudioBufferAppendEvent\n | InputAudioBufferCommitEvent\n | InputAudioBufferClearEvent\n | ConversationItemCreateEvent\n | ConversationItemTruncateEvent\n | ConversationItemDeleteEvent\n | ResponseCreateEvent\n | ResponseCancelEvent;\n\ninterface BaseServerEvent {\n event_id: string;\n type: ServerEventType;\n}\n\nexport interface ErrorEvent extends BaseServerEvent {\n type: 'error';\n error: {\n type: 'invalid_request_error' | 'server_error' | string;\n code?: string;\n message: string;\n param: string;\n event_id: string;\n };\n}\n\nexport interface SessionCreatedEvent extends BaseServerEvent {\n type: 'session.created';\n session: SessionResource;\n}\n\nexport interface SessionUpdatedEvent extends BaseServerEvent {\n type: 'session.updated';\n session: SessionResource;\n}\n\nexport interface ConversationCreatedEvent extends BaseServerEvent {\n type: 'conversation.created';\n conversation: ConversationResource;\n}\n\nexport interface InputAudioBufferCommittedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.committed';\n item_id: string;\n}\n\nexport interface InputAudioBufferClearedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.cleared';\n}\n\nexport interface InputAudioBufferSpeechStartedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_started';\n audio_start_ms: number;\n item_id: string;\n}\n\nexport interface InputAudioBufferSpeechStoppedEvent extends BaseServerEvent {\n type: 'input_audio_buffer.speech_stopped';\n audio_end_ms: number;\n item_id: string;\n}\n\nexport interface ConversationItemCreatedEvent extends BaseServerEvent {\n type: 'conversation.item.created';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemAddedEvent extends BaseServerEvent {\n type: 'conversation.item.added';\n previous_item_id: string;\n item: ItemResource;\n}\n\nexport interface ConversationItemInputAudioTranscriptionCompletedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.completed';\n item_id: string;\n content_index: number;\n transcript: string;\n}\n\nexport interface ConversationItemInputAudioTranscriptionFailedEvent extends BaseServerEvent {\n type: 'conversation.item.input_audio_transcription.failed';\n item_id: string;\n content_index: number;\n error: {\n type: string;\n code?: string;\n message: string;\n param: null;\n };\n}\n\nexport interface ConversationItemTruncatedEvent extends BaseServerEvent {\n type: 'conversation.item.truncated';\n item_id: string;\n content_index: number;\n audio_end_ms: number;\n}\n\nexport interface ConversationItemDeletedEvent extends BaseServerEvent {\n type: 'conversation.item.deleted';\n item_id: string;\n}\n\nexport interface ResponseCreatedEvent extends BaseServerEvent {\n type: 'response.created';\n response: ResponseResource;\n}\n\nexport interface ResponseDoneEvent extends BaseServerEvent {\n type: 'response.done';\n response: ResponseResource;\n}\n\nexport interface ResponseOutputItemAddedEvent extends BaseServerEvent {\n type: 'response.output_item.added';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseOutputItemDoneEvent extends BaseServerEvent {\n type: 'response.output_item.done';\n response_id: string;\n output_index: number;\n item: ItemResource;\n}\n\nexport interface ResponseContentPartAddedEvent extends BaseServerEvent {\n type: 'response.content_part.added';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseContentPartDoneEvent extends BaseServerEvent {\n type: 'response.content_part.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n part: ContentPart;\n}\n\nexport interface ResponseTextDeltaEvent extends BaseServerEvent {\n type: 'response.text.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseTextDoneEvent extends BaseServerEvent {\n type: 'response.text.done';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n text: string;\n}\n\nexport interface ResponseAudioTranscriptDeltaEvent extends BaseServerEvent {\n type: 'response.audio_transcript.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: string;\n}\n\nexport interface ResponseAudioTranscriptDoneEvent extends BaseServerEvent {\n type: 'response.audio_transcript.done';\n response_id: string;\n output_index: number;\n content_index: number;\n transcript: string;\n}\n\nexport interface ResponseAudioDeltaEvent extends BaseServerEvent {\n type: 'response.audio.delta';\n response_id: string;\n item_id: string;\n output_index: number;\n content_index: number;\n delta: AudioBase64Bytes;\n}\n\nexport interface ResponseAudioDoneEvent extends BaseServerEvent {\n type: 'response.audio.done';\n response_id: string;\n output_index: number;\n content_index: number;\n}\n\nexport interface ResponseFunctionCallArgumentsDeltaEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.delta';\n response_id: string;\n output_index: number;\n delta: string;\n}\n\nexport interface ResponseFunctionCallArgumentsDoneEvent extends BaseServerEvent {\n type: 'response.function_call_arguments.done';\n response_id: string;\n output_index: number;\n arguments: string;\n}\n\nexport interface RateLimitsUpdatedEvent extends BaseServerEvent {\n type: 'rate_limits.updated';\n rate_limits: {\n name: 'requests' | 'tokens' | 'input_tokens' | 'output_tokens' | string;\n limit: number;\n remaining: number;\n reset_seconds: number;\n }[];\n}\n\nexport type ServerEvent =\n | ErrorEvent\n | SessionCreatedEvent\n | SessionUpdatedEvent\n | ConversationCreatedEvent\n | InputAudioBufferCommittedEvent\n | InputAudioBufferClearedEvent\n | InputAudioBufferSpeechStartedEvent\n | InputAudioBufferSpeechStoppedEvent\n | ConversationItemCreatedEvent\n | ConversationItemAddedEvent // GA: renamed from conversation.item.created\n | ConversationItemInputAudioTranscriptionCompletedEvent\n | ConversationItemInputAudioTranscriptionFailedEvent\n | ConversationItemTruncatedEvent\n | ConversationItemDeletedEvent\n | ResponseCreatedEvent\n | ResponseDoneEvent\n | ResponseOutputItemAddedEvent\n | ResponseOutputItemDoneEvent\n | ResponseContentPartAddedEvent\n | ResponseContentPartDoneEvent\n | ResponseTextDeltaEvent\n | ResponseTextDoneEvent\n | ResponseAudioTranscriptDeltaEvent\n | ResponseAudioTranscriptDoneEvent\n | ResponseAudioDeltaEvent\n | ResponseAudioDoneEvent\n | ResponseFunctionCallArgumentsDeltaEvent\n | ResponseFunctionCallArgumentsDoneEvent\n | RateLimitsUpdatedEvent;\n"],"mappings":"AAIO,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAEvB,MAAM,WAAW;","names":[]}
|