ObservabilityAiAssistantClient¶
Client for the Kibana Observability AI Assistant API.
The Observability AI Assistant chat completion API generates responses from a large language model (LLM) based on the current conversation context. It also handles any tool (function) requests within the conversation, which may trigger multiple calls to the underlying LLM.
Note
The API is marked as technical preview in Kibana 9.4 and may change or be removed in a future release.
The API requires a preconfigured AI (LLM) connector (for example an OpenAI,
Azure OpenAI or Amazon Bedrock connector) identified by connector_id.
Conversations are space-scoped: every method accepts an optional space_id
to target a specific space.
- class kibana._sync.client.observability_ai_assistant.ObservabilityAiAssistantClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
NamespaceClientClient for the Kibana Observability AI Assistant API.
The Observability AI Assistant chat completion API generates responses from a large language model (LLM) based on the current conversation context. It also handles any tool (function) requests within the conversation, which may trigger multiple calls to the underlying LLM.
The API is marked as Technical Preview in Kibana 9.4 and may change or be removed in a future release.
The API requires a preconfigured AI (LLM) connector (for example an OpenAI, Azure OpenAI or Amazon Bedrock connector) identified by
connector_id. Conversations are space-scoped: every method accepts an optionalspace_idto target a specific space (Nonetargets the default space or the space the client is scoped to).Note
On success (HTTP 200) Kibana streams the model output as server-sent events (
data: {...}chunks terminated bydata: [DONE]) with content typeapplication/octet-stream, so the returned response body is the raw event stream rather than a parsed JSON object.Example
>>> from kibana import Kibana >>> client = Kibana("http://localhost:5601", api_key="...") >>> >>> response = client.observability_ai_assistant.chat_complete( ... connector_id="my-openai-connector", ... persist=False, ... messages=[ ... { ... "@timestamp": "2026-07-03T00:00:00.000Z", ... "message": { ... "role": "user", ... "content": "Is my Elasticsearch cluster healthy?", ... }, ... } ... ], ... ) >>> print(response.body) # raw SSE stream of completion chunks
Chat Completion
from kibana import Kibana client = Kibana("http://localhost:5601", api_key="your_api_key") response = client.observability_ai_assistant.chat_complete( connector_id="my-openai-connector", persist=False, messages=[ { "@timestamp": "2026-07-03T00:00:00.000Z", "message": { "role": "user", "content": "Is my Elasticsearch cluster healthy?", }, } ], ) print(response.body) # raw SSE stream of completion chunks
Note
On success (HTTP 200) Kibana streams the model output as server-sent events (
data: {...}chunks terminated bydata: [DONE]) with content typeapplication/octet-stream, so the returned response body is the raw event stream rather than a parsed JSON object.Persisting Conversations
Set
persist=Trueto store the conversation so it can be continued later (and passconversation_idto append to an existing one):response = client.observability_ai_assistant.chat_complete( connector_id="my-openai-connector", persist=True, title="Cluster health check", messages=[ { "@timestamp": "2026-07-03T00:00:00.000Z", "message": { "role": "user", "content": "Summarize the alerts from the last hour.", }, } ], )
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the ObservabilityAiAssistantClient.
- Parameters:
Example
>>> ai_assistant_client = ObservabilityAiAssistantClient(kibana_client)
- chat_complete(*, messages, connector_id, persist, actions=None, conversation_id=None, disable_functions=None, instructions=None, title=None, space_id=None, validate_spaces=None)[source]¶
Generate a chat completion.
Technical preview in 9.4. Creates a new chat completion by using the Observability AI Assistant. The API returns the model’s response based on the current conversation context, and handles any tool requests within the conversation (which may trigger multiple calls to the underlying LLM).
- Parameters:
messages (list[dict[str, Any]]) – An array of message objects containing the conversation history. Each message requires
@timestamp(ISO 8601 string) and amessageobject with at least arole(one of"system","assistant","function","user","elastic") plus optionalcontent,name,event,dataandfunction_callfields.connector_id (str) – A unique identifier for the AI (LLM) connector.
persist (bool) – Indicates whether the conversation should be saved to storage. If True, the conversation is saved and available in Kibana.
actions (list[dict[str, Any]] | None) – An array of function definitions the model may call. Each function object has
name,descriptionand JSON schemaparameters.conversation_id (str | None) – A unique identifier for the conversation if you are continuing an existing conversation.
disable_functions (bool | None) – Flag indicating whether all function calls should be disabled for the conversation. If True, no calls to functions are made.
instructions (list[str | dict[str, Any]] | None) – An array of instruction objects, which can be either simple strings or detailed objects with
idandtextfields.title (str | None) – A title for the conversation.
space_id (str | None) – Optional space ID to run the conversation in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is the raw server-sent event stream of chat completion chunks (
data: {...}lines terminated bydata: [DONE]). At runtime Kibana serves it with content typeapplication/octet-stream, so the body is bytes, not parsed JSON.- Raises:
BadRequestError – If the request body fails validation (e.g. missing
messagesorconnectorId).NotFoundError – If no connector or inference endpoint exists for
connector_id.AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> response = client.observability_ai_assistant.chat_complete( ... connector_id="my-openai-connector", ... persist=False, ... disable_functions=True, ... messages=[ ... { ... "@timestamp": "2026-07-03T00:00:00.000Z", ... "message": {"role": "user", "content": "Hello"}, ... } ... ], ... instructions=["Answer concisely."], ... ) >>> print(response.meta.status) 200
AsyncObservabilityAiAssistantClient¶
Asynchronous version of the ObservabilityAiAssistantClient for use with async/await syntax.
- class kibana._async.client.observability_ai_assistant.AsyncObservabilityAiAssistantClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
AsyncNamespaceClientAsync client for the Kibana Observability AI Assistant API.
The Observability AI Assistant chat completion API generates responses from a large language model (LLM) based on the current conversation context. It also handles any tool (function) requests within the conversation, which may trigger multiple calls to the underlying LLM.
The API is marked as Technical Preview in Kibana 9.4 and may change or be removed in a future release.
The API requires a preconfigured AI (LLM) connector (for example an OpenAI, Azure OpenAI or Amazon Bedrock connector) identified by
connector_id. Conversations are space-scoped: every method accepts an optionalspace_idto target a specific space (Nonetargets the default space or the space the client is scoped to).Note
On success (HTTP 200) Kibana streams the model output as server-sent events (
data: {...}chunks terminated bydata: [DONE]) with content typeapplication/octet-stream, so the returned response body is the raw event stream rather than a parsed JSON object.Example
>>> from kibana import AsyncKibana >>> client = AsyncKibana("http://localhost:5601", api_key="...") >>> >>> response = await client.observability_ai_assistant.chat_complete( ... connector_id="my-openai-connector", ... persist=False, ... messages=[ ... { ... "@timestamp": "2026-07-03T00:00:00.000Z", ... "message": { ... "role": "user", ... "content": "Is my Elasticsearch cluster healthy?", ... }, ... } ... ], ... ) >>> print(response.body) # raw SSE stream of completion chunks
Usage
The AsyncObservabilityAiAssistantClient provides the same methods as ObservabilityAiAssistantClient but all methods are async and must be awaited:
from kibana import AsyncKibana import asyncio async def main(): async with AsyncKibana("http://localhost:5601") as client: response = await client.observability_ai_assistant.chat_complete( connector_id="my-openai-connector", persist=False, messages=[ { "@timestamp": "2026-07-03T00:00:00.000Z", "message": { "role": "user", "content": "Is my cluster healthy?", }, } ], ) asyncio.run(main())
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the AsyncObservabilityAiAssistantClient.
- Parameters:
client (AsyncKibana) – The parent AsyncKibana client instance to delegate requests to.
default_space_id (str | None) – Optional default space ID for all operations.
validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).
Example
>>> ai_assistant_client = AsyncObservabilityAiAssistantClient(kibana_client)
- async chat_complete(*, messages, connector_id, persist, actions=None, conversation_id=None, disable_functions=None, instructions=None, title=None, space_id=None, validate_spaces=None)[source]¶
Generate a chat completion.
Technical preview in 9.4. Creates a new chat completion by using the Observability AI Assistant. The API returns the model’s response based on the current conversation context, and handles any tool requests within the conversation (which may trigger multiple calls to the underlying LLM).
- Parameters:
messages (list[dict[str, Any]]) – An array of message objects containing the conversation history. Each message requires
@timestamp(ISO 8601 string) and amessageobject with at least arole(one of"system","assistant","function","user","elastic") plus optionalcontent,name,event,dataandfunction_callfields.connector_id (str) – A unique identifier for the AI (LLM) connector.
persist (bool) – Indicates whether the conversation should be saved to storage. If True, the conversation is saved and available in Kibana.
actions (list[dict[str, Any]] | None) – An array of function definitions the model may call. Each function object has
name,descriptionand JSON schemaparameters.conversation_id (str | None) – A unique identifier for the conversation if you are continuing an existing conversation.
disable_functions (bool | None) – Flag indicating whether all function calls should be disabled for the conversation. If True, no calls to functions are made.
instructions (list[str | dict[str, Any]] | None) – An array of instruction objects, which can be either simple strings or detailed objects with
idandtextfields.title (str | None) – A title for the conversation.
space_id (str | None) – Optional space ID to run the conversation in.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is the raw server-sent event stream of chat completion chunks (
data: {...}lines terminated bydata: [DONE]). At runtime Kibana serves it with content typeapplication/octet-stream, so the body is bytes, not parsed JSON.- Raises:
BadRequestError – If the request body fails validation (e.g. missing
messagesorconnectorId).NotFoundError – If no connector or inference endpoint exists for
connector_id.AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> response = await client.observability_ai_assistant.chat_complete( ... connector_id="my-openai-connector", ... persist=False, ... disable_functions=True, ... messages=[ ... { ... "@timestamp": "2026-07-03T00:00:00.000Z", ... "message": {"role": "user", "content": "Hello"}, ... } ... ], ... instructions=["Answer concisely."], ... ) >>> print(response.meta.status) 200