generative-ai-python

google.generativeai.types.AsyncGenerateContentResponse

This is the async version of genai.GenerateContentResponse.

`candidates` The list of candidate responses.
`parts` A quick accessor equivalent to `self.candidates[0].content.parts`
`prompt_feedback`
`text` A quick accessor equivalent to `self.candidates[0].content.parts[0].text`
`usage_metadata`

Methods

from_aiterator

View source

from_response

View source

resolve

View source

to_dict

View source

Returns the result as a JSON-compatible dict.

Note: This doesn’t capture the iterator state when streaming, it only captures the accumulated GenerateContentResponse fields.

>>> import json
>>> response = model.generate_content('Hello?')
>>> json.dumps(response.to_dict())