Skip to content

Commit c5896f1

Browse files
committed
Live API v1
1 parent 7098537 commit c5896f1

36 files changed

+2562
-14
lines changed

common/api-review/ai.api.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const AIErrorCode: {
3232
readonly REQUEST_ERROR: "request-error";
3333
readonly RESPONSE_ERROR: "response-error";
3434
readonly FETCH_ERROR: "fetch-error";
35+
readonly SESSION_CLOSED: "session-closed";
3536
readonly INVALID_CONTENT: "invalid-content";
3637
readonly API_NOT_ENABLED: "api-not-enabled";
3738
readonly INVALID_SCHEMA: "invalid-schema";
@@ -262,6 +263,7 @@ export type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
262263
export interface FunctionCall {
263264
// (undocumented)
264265
args: object;
266+
id?: string;
265267
// (undocumented)
266268
name: string;
267269
}
@@ -310,6 +312,7 @@ export interface FunctionDeclarationsTool {
310312

311313
// @public
312314
export interface FunctionResponse {
315+
id?: string;
313316
// (undocumented)
314317
name: string;
315318
// (undocumented)
@@ -444,6 +447,9 @@ export function getGenerativeModel(ai: AI, modelParams: ModelParams, requestOpti
444447
// @beta
445448
export function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
446449

450+
// @beta
451+
export function getLiveGenerativeModel(ai: AI, modelParams: LiveModelParams): LiveGenerativeModel;
452+
447453
// @public
448454
export class GoogleAIBackend extends Backend {
449455
constructor();
@@ -699,6 +705,129 @@ export class IntegerSchema extends Schema {
699705
constructor(schemaParams?: SchemaParams);
700706
}
701707

708+
// Warning: (ae-internal-missing-underscore) The name "LiveClientContent" should be prefixed with an underscore because the declaration is marked as @internal
709+
//
710+
// @internal
711+
export interface LiveClientContent {
712+
// (undocumented)
713+
clientContent: {
714+
turns: [Content];
715+
turnComplete: boolean;
716+
};
717+
}
718+
719+
// Warning: (ae-internal-missing-underscore) The name "LiveClientRealtimeInput" should be prefixed with an underscore because the declaration is marked as @internal
720+
//
721+
// @internal
722+
export interface LiveClientRealtimeInput {
723+
// (undocumented)
724+
realtimeInput: {
725+
mediaChunks: GenerativeContentBlob[];
726+
};
727+
}
728+
729+
// Warning: (ae-internal-missing-underscore) The name "LiveClientSetup" should be prefixed with an underscore because the declaration is marked as @internal
730+
//
731+
// @internal
732+
export interface LiveClientSetup {
733+
// (undocumented)
734+
setup: {
735+
model: string;
736+
generationConfig?: LiveGenerationConfig;
737+
};
738+
}
739+
740+
// @public
741+
export interface LiveGenerationConfig {
742+
candidateCount?: number;
743+
frequencyPenalty?: number;
744+
maxOutputTokens?: number;
745+
presencePenalty?: number;
746+
// Warning: (ae-incompatible-release-tags) The symbol "responseModalities" is marked as @public, but its signature references "ResponseModality" which is marked as @beta
747+
responseModalities?: [ResponseModality];
748+
// (undocumented)
749+
speechConfig?: SpeechConfig;
750+
temperature?: number;
751+
topK?: number;
752+
topP?: number;
753+
}
754+
755+
// @beta
756+
export class LiveGenerativeModel extends AIModel {
757+
// @internal
758+
constructor(ai: AI, modelParams: LiveModelParams, _webSocketHandler: WebSocketHandler);
759+
connect(): Promise<LiveSession>;
760+
// (undocumented)
761+
generationConfig: LiveGenerationConfig;
762+
// (undocumented)
763+
systemInstruction?: Content;
764+
// (undocumented)
765+
toolConfig?: ToolConfig;
766+
// (undocumented)
767+
tools?: Tool[];
768+
// Warning: (ae-forgotten-export) The symbol "WebSocketHandler" needs to be exported by the entry point index.d.ts
769+
//
770+
// (undocumented)
771+
_webSocketHandler: WebSocketHandler;
772+
}
773+
774+
// @public
775+
export interface LiveModelParams {
776+
generationConfig?: LiveGenerationConfig;
777+
model: string;
778+
// (undocumented)
779+
systemInstruction?: string | Part | Content;
780+
// (undocumented)
781+
toolConfig?: ToolConfig;
782+
// (undocumented)
783+
tools?: Tool[];
784+
}
785+
786+
// @beta
787+
export const LiveResponseType: {
788+
SERVER_CONTENT: string;
789+
TOOL_CALL: string;
790+
TOOL_CALL_CANCELLATION: string;
791+
};
792+
793+
// @beta
794+
export type LiveResponseType = (typeof LiveResponseType)[keyof typeof LiveResponseType];
795+
796+
// @beta
797+
export interface LiveServerContent {
798+
interrupted?: boolean;
799+
modelTurn?: Content;
800+
turnComplete?: boolean;
801+
// (undocumented)
802+
type: 'serverContent';
803+
}
804+
805+
// @beta
806+
export interface LiveServerToolCall {
807+
functionCalls: FunctionCall[];
808+
// (undocumented)
809+
type: 'toolCall';
810+
}
811+
812+
// @beta
813+
export interface LiveServerToolCallCancellation {
814+
functionIds: string[];
815+
// (undocumented)
816+
type: 'toolCallCancellation';
817+
}
818+
819+
// @beta
820+
export class LiveSession {
821+
// @internal
822+
constructor(webSocketHandler: WebSocketHandler, serverMessages: AsyncGenerator<unknown>);
823+
close(): Promise<void>;
824+
isClosed: boolean;
825+
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation>;
826+
send(request: string | Array<string | Part>, turnComplete?: boolean): Promise<void>;
827+
sendMediaChunks(mediaChunks: GenerativeContentBlob[]): Promise<void>;
828+
sendMediaStream(mediaChunkStream: ReadableStream<GenerativeContentBlob>): Promise<void>;
829+
}
830+
702831
// @public
703832
export const Modality: {
704833
readonly MODALITY_UNSPECIFIED: "MODALITY_UNSPECIFIED";
@@ -763,6 +892,11 @@ export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionRespon
763892
// @public
764893
export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];
765894

895+
// @public
896+
export interface PrebuiltVoiceConfig {
897+
voiceConfig?: string;
898+
}
899+
766900
// @public
767901
export interface PromptFeedback {
768902
// (undocumented)
@@ -926,6 +1060,11 @@ export interface Segment {
9261060
text: string;
9271061
}
9281062

1063+
// @public
1064+
export interface SpeechConfig {
1065+
voiceConfig?: VoiceConfig;
1066+
}
1067+
9291068
// @public
9301069
export interface StartChatParams extends BaseParams {
9311070
// (undocumented)
@@ -1003,6 +1142,11 @@ export interface VideoMetadata {
10031142
startOffset: string;
10041143
}
10051144

1145+
// @public
1146+
export interface VoiceConfig {
1147+
prebuiltVoiceConfig?: PrebuiltVoiceConfig;
1148+
}
1149+
10061150
// @public (undocumented)
10071151
export interface WebAttribution {
10081152
// (undocumented)

docs-devsite/_toc.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ toc:
108108
path: /docs/reference/js/ai.inlinedatapart.md
109109
- title: IntegerSchema
110110
path: /docs/reference/js/ai.integerschema.md
111+
- title: LiveGenerationConfig
112+
path: /docs/reference/js/ai.livegenerationconfig.md
113+
- title: LiveGenerativeModel
114+
path: /docs/reference/js/ai.livegenerativemodel.md
115+
- title: LiveModelParams
116+
path: /docs/reference/js/ai.livemodelparams.md
117+
- title: LiveServerContent
118+
path: /docs/reference/js/ai.liveservercontent.md
119+
- title: LiveServerToolCall
120+
path: /docs/reference/js/ai.liveservertoolcall.md
121+
- title: LiveServerToolCallCancellation
122+
path: /docs/reference/js/ai.liveservertoolcallcancellation.md
123+
- title: LiveSession
124+
path: /docs/reference/js/ai.livesession.md
111125
- title: ModalityTokenCount
112126
path: /docs/reference/js/ai.modalitytokencount.md
113127
- title: ModelParams
@@ -118,6 +132,8 @@ toc:
118132
path: /docs/reference/js/ai.objectschema.md
119133
- title: ObjectSchemaRequest
120134
path: /docs/reference/js/ai.objectschemarequest.md
135+
- title: PrebuiltVoiceConfig
136+
path: /docs/reference/js/ai.prebuiltvoiceconfig.md
121137
- title: PromptFeedback
122138
path: /docs/reference/js/ai.promptfeedback.md
123139
- title: RequestOptions
@@ -142,6 +158,8 @@ toc:
142158
path: /docs/reference/js/ai.searchentrypoint.md
143159
- title: Segment
144160
path: /docs/reference/js/ai.segment.md
161+
- title: SpeechConfig
162+
path: /docs/reference/js/ai.speechconfig.md
145163
- title: StartChatParams
146164
path: /docs/reference/js/ai.startchatparams.md
147165
- title: StringSchema
@@ -158,6 +176,8 @@ toc:
158176
path: /docs/reference/js/ai.vertexaibackend.md
159177
- title: VideoMetadata
160178
path: /docs/reference/js/ai.videometadata.md
179+
- title: VoiceConfig
180+
path: /docs/reference/js/ai.voiceconfig.md
161181
- title: WebAttribution
162182
path: /docs/reference/js/ai.webattribution.md
163183
- title: WebGroundingChunk

docs-devsite/ai.functioncall.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface FunctionCall
2323
| Property | Type | Description |
2424
| --- | --- | --- |
2525
| [args](./ai.functioncall.md#functioncallargs) | object | |
26+
| [id](./ai.functioncall.md#functioncallid) | string | The id of the function call. This must be sent back in the associated [FunctionResponse](./ai.functionresponse.md#functionresponse_interface)<!-- -->.<!-- -->This property is only supported in the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->), this property will be <code>undefined</code>. |
2627
| [name](./ai.functioncall.md#functioncallname) | string | |
2728

2829
## FunctionCall.args
@@ -33,6 +34,18 @@ export interface FunctionCall
3334
args: object;
3435
```
3536

37+
## FunctionCall.id
38+
39+
The id of the function call. This must be sent back in the associated [FunctionResponse](./ai.functionresponse.md#functionresponse_interface)<!-- -->.
40+
41+
This property is only supported in the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->), this property will be `undefined`<!-- -->.
42+
43+
<b>Signature:</b>
44+
45+
```typescript
46+
id?: string;
47+
```
48+
3649
## FunctionCall.name
3750

3851
<b>Signature:</b>

docs-devsite/ai.functionresponse.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,22 @@ export interface FunctionResponse
2222

2323
| Property | Type | Description |
2424
| --- | --- | --- |
25+
| [id](./ai.functionresponse.md#functionresponseid) | string | The id of the [FunctionCall](./ai.functioncall.md#functioncall_interface)<!-- -->.<!-- -->This property is only supported in the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->), this property will be <code>undefined</code>. |
2526
| [name](./ai.functionresponse.md#functionresponsename) | string | |
2627
| [response](./ai.functionresponse.md#functionresponseresponse) | object | |
2728

29+
## FunctionResponse.id
30+
31+
The id of the [FunctionCall](./ai.functioncall.md#functioncall_interface)<!-- -->.
32+
33+
This property is only supported in the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->), this property will be `undefined`<!-- -->.
34+
35+
<b>Signature:</b>
36+
37+
```typescript
38+
id?: string;
39+
```
40+
2841
## FunctionResponse.name
2942

3043
<b>Signature:</b>

0 commit comments

Comments
 (0)