diff --git a/.changeset/dirty-snails-unite.md b/.changeset/dirty-snails-unite.md new file mode 100644 index 00000000..1d487fbc --- /dev/null +++ b/.changeset/dirty-snails-unite.md @@ -0,0 +1,5 @@ +--- +"@google/generative-ai": minor +--- + +Added responseMimeType to GenerationConfig to allow for JSON formatted responses. diff --git a/docs/reference/main/generative-ai.generationconfig.md b/docs/reference/main/generative-ai.generationconfig.md index 2cb26cd6..633c5fc2 100644 --- a/docs/reference/main/generative-ai.generationconfig.md +++ b/docs/reference/main/generative-ai.generationconfig.md @@ -18,6 +18,7 @@ export interface GenerationConfig | --- | --- | --- | --- | | [candidateCount?](./generative-ai.generationconfig.candidatecount.md) | | number | _(Optional)_ | | [maxOutputTokens?](./generative-ai.generationconfig.maxoutputtokens.md) | | number | _(Optional)_ | +| [responseMimeType?](./generative-ai.generationconfig.responsemimetype.md) | | string | _(Optional)_ Output response mimetype of the generated candidate text. Supported mimetype: text/plain: (default) Text output. application/json: JSON response in the candidates. | | [stopSequences?](./generative-ai.generationconfig.stopsequences.md) | | string\[\] | _(Optional)_ | | [temperature?](./generative-ai.generationconfig.temperature.md) | | number | _(Optional)_ | | [topK?](./generative-ai.generationconfig.topk.md) | | number | _(Optional)_ | diff --git a/docs/reference/main/generative-ai.generationconfig.responsemimetype.md b/docs/reference/main/generative-ai.generationconfig.responsemimetype.md new file mode 100644 index 00000000..3620d925 --- /dev/null +++ b/docs/reference/main/generative-ai.generationconfig.responsemimetype.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@google/generative-ai](./generative-ai.md) > [GenerationConfig](./generative-ai.generationconfig.md) > [responseMimeType](./generative-ai.generationconfig.responsemimetype.md) + +## GenerationConfig.responseMimeType property + +Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`: (default) Text output. `application/json`: JSON response in the candidates. + +**Signature:** + +```typescript +responseMimeType?: string; +``` diff --git a/packages/main/types/requests.ts b/packages/main/types/requests.ts index eefa3825..6787ea8b 100644 --- a/packages/main/types/requests.ts +++ b/packages/main/types/requests.ts @@ -74,6 +74,13 @@ export interface GenerationConfig { temperature?: number; topP?: number; topK?: number; + /** + * Output response mimetype of the generated candidate text. + * Supported mimetype: + * `text/plain`: (default) Text output. + * `application/json`: JSON response in the candidates. + */ + responseMimeType?: string; } /**