- create - Create a chat response
Run an assistant turn. Set stream to true to receive server-sent events; otherwise the response is a typed JSON response object.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.chat.create(input="<value>", stream=False, store=True)
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
input |
models.Input | ✔️ | Either a plain string (single user turn) or a chronological array of user/assistant messages. The final array message must be user. |
stream |
Optional[bool] | ➖ | When true, respond with text/event-stream. When false or omitted, respond with application/json. |
store |
Optional[bool] | ➖ | When true (default), persist the interaction and return a conversation_id. When false, run ephemerally with no persistence. |
conversation_id |
Optional[str] | ➖ | Continue an existing stored conversation. Incompatible with message-array input and with store: false. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.PlatformChatCreateResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.PlatformProblemDetailError | 400, 401, 403, 404, 408, 413, 422, 429 | application/problem+json |
| errors.PlatformProblemDetailError | 500, 503 | application/problem+json |
| errors.GleanError | 4XX, 5XX | */* |