# Class AdkApp (1.153.1)

1.153.1 (latest) 1.153.0 1.152.0 1.151.0 1.150.0 1.149.0 1.148.1 1.147.0 1.146.0 1.145.0 1.144.0 1.143.0 1.142.0 1.141.0 1.140.0 1.139.0 1.138.0 1.137.0 1.136.0 1.135.0 1.134.0 1.133.0 1.132.0 1.131.0 1.130.0 1.129.0 1.122.0 1.121.0 1.120.0 1.119.0 1.118.0 1.117.0 1.95.1 1.94.0 1.93.1 1.92.0 1.91.0 1.90.0 1.89.0 1.88.0 1.87.0 1.86.0 1.85.0 1.84.0 1.83.0 1.82.0 1.81.0 1.80.0 1.79.0 1.78.0 1.77.0 1.76.0 1.75.0 1.74.0 1.73.0 1.72.0 1.71.1 1.70.0 1.69.0 1.68.0 1.67.1 1.66.0 1.65.0 1.63.0 1.62.0 1.60.0 1.59.0

    AdkApp(
        *,
        agent: BaseAgent,
        plugins: typing.Optional[typing.List[BasePlugin]] = None,
        enable_tracing: typing.Optional[bool] = None,
        session_service_builder: typing.Optional[
            typing.Callable[[...], BaseSessionService]
        ] = None,
        artifact_service_builder: typing.Optional[
            typing.Callable[[...], BaseArtifactService]
        ] = None,
        memory_service_builder: typing.Optional[
            typing.Callable[[...], BaseMemoryService]
        ] = None,
        credential_service_builder: typing.Optional[
            typing.Callable[[...], BaseCredentialService]
        ] = None,
        env_vars: typing.Optional[typing.Dict[str, str]] = None
    )

An ADK Application.

## Methods

### AdkApp

    AdkApp(
        *,
        agent: BaseAgent,
        plugins: typing.Optional[typing.List[BasePlugin]] = None,
        enable_tracing: typing.Optional[bool] = None,
        session_service_builder: typing.Optional[
            typing.Callable[[...], BaseSessionService]
        ] = None,
        artifact_service_builder: typing.Optional[
            typing.Callable[[...], BaseArtifactService]
        ] = None,
        memory_service_builder: typing.Optional[
            typing.Callable[[...], BaseMemoryService]
        ] = None,
        credential_service_builder: typing.Optional[
            typing.Callable[[...], BaseCredentialService]
        ] = None,
        env_vars: typing.Optional[typing.Dict[str, str]] = None
    )

An ADK Application.

### async_add_session_to_memory

    async_add_session_to_memory(*, session: typing.Dict[str, typing.Any])

Generates memories.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `session` | `Dict[str, Any]` Required. The session to use for generating memories. It should be a dictionary representing an ADK Session object, e.g. session.model_dump(mode="json"). |

### async_create_session

    async_create_session(
        *,
        user_id: str,
        session_id: typing.Optional[str] = None,
        state: typing.Optional[typing.Dict[str, typing.Any]] = None,
        **kwargs
    )

Creates a new session.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `user_id` | `str` Required. The ID of the user. |
| `session_id` | `str` Optional. The ID of the session. If not provided, an ID will be be generated for the session. |
| `state` | `dict[str, Any]` Optional. The initial state of the session. |
| `\*\*kwargs` | `dict[str, Any]` Optional. Additional keyword arguments to pass to the session service. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Session` | The newly created session instance. |

### async_delete_session

    async_delete_session(*, user_id: str, session_id: str, **kwargs)

Deletes a session for the given user.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `user_id` | `str` Required. The ID of the user. |
| `session_id` | `str` Required. The ID of the session. |
| `\*\*kwargs` | `dict[str, Any]` Optional. Additional keyword arguments to pass to the session service. |

### async_get_session

    async_get_session(*, user_id: str, session_id: str, **kwargs)

Get a session for the given user.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `user_id` | `str` Required. The ID of the user. |
| `session_id` | `str` Required. The ID of the session. |
| `\*\*kwargs` | `dict[str, Any]` Optional. Additional keyword arguments to pass to the session service. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `RuntimeError` | If the session is not found. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Session` | The session instance (if any). It returns None if the session is not found. |

### async_list_sessions

    async_list_sessions(*, user_id: str, **kwargs)

List sessions for the given user.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `user_id` | `str` Required. The ID of the user. |
| `\*\*kwargs` | `dict[str, Any]` Optional. Additional keyword arguments to pass to the session service. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ListSessionsResponse` | The list of sessions. |

### async_search_memory

    async_search_memory(*, user_id: str, query: str)

Searches memories for the given user.

### async_stream_query

    async_stream_query(
        *,
        message: typing.Union[str, typing.Dict[str, typing.Any]],
        user_id: str,
        session_id: typing.Optional[str] = None,
        run_config: typing.Optional[typing.Dict[str, typing.Any]] = None,
        **kwargs
    ) -> typing.AsyncIterable[typing.Dict[str, typing.Any]]

Streams responses asynchronously from the ADK application.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `message` | `str` Required. The message to stream responses for. |
| `user_id` | `str` Required. The ID of the user. |
| `session_id` | `str` Optional. The ID of the session. If not provided, a new session will be created for the user. |
| `run_config` | `Optional[Dict[str, Any]]` Optional. The run config to use for the query. If you want to pass in a `run_config` pydantic object, you can pass in a dict representing it as `run_config.model_dump(mode="json")`. |
| `\*\*kwargs` | `dict[str, Any] :Yields: Event dictionaries asynchronously.` Optional. Additional keyword arguments to pass to the runner. |

### bidi_stream_query

    bidi_stream_query(request_queue: typing.Any) -> typing.AsyncIterable[typing.Any]

Bidi streaming query the ADK application.

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `TypeError` | If the request_queue is not an asyncio.Queue instance. |
| `ValueError` | If the first request does not have a user_id. |
| `ValidationError` | If failed to convert to LiveRequest. :Yields: The stream responses of querying the ADK application. |

### clone

    clone()

Returns a clone of the ADK application.

### create_session

    create_session(
        *,
        user_id: str,
        session_id: typing.Optional[str] = None,
        state: typing.Optional[typing.Dict[str, typing.Any]] = None,
        **kwargs
    )

Creates a new session.

### delete_session

    delete_session(*, user_id: str, session_id: str, **kwargs)

Deletes a session for the given user.

### get_session

    get_session(*, user_id: str, session_id: str, **kwargs)

Get a session for the given user.

### list_sessions

    list_sessions(*, user_id: str, **kwargs)

List sessions for the given user.

### register_operations

    register_operations() -> typing.Dict[str, typing.List[str]]

Registers the operations of the ADK application.

### set_up

    set_up()

Sets up the ADK application.

### stream_query

    stream_query(
        *,
        message: typing.Union[str, typing.Dict[str, typing.Any]],
        user_id: str,
        session_id: typing.Optional[str] = None,
        run_config: typing.Optional[typing.Dict[str, typing.Any]] = None,
        **kwargs
    )

Streams responses from the ADK application in response to a message.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `message` | `Union[str, Dict[str, Any]]` Required. The message to stream responses for. |
| `user_id` | `str` Required. The ID of the user. |
| `session_id` | `str` Optional. The ID of the session. If not provided, a new session will be created for the user. |
| `run_config` | `Optional[Dict[str, Any]]` Optional. The run config to use for the query. If you want to pass in a `run_config` pydantic object, you can pass in a dict representing it as `run_config.model_dump(mode="json")`. |
| `\*\*kwargs` | `dict[str, Any] :Yields: The output of querying the ADK application.` Optional. Additional keyword arguments to pass to the runner. |