Create a new assistant.
Useful when graph is configurable and you want to create different assistants based on different configurations.
create(
self,
graph_id: str | None,
config: Config | None = None,
*,
context: Context | None = None,
metadata: Json = None,
assistant_id: str | None = None,
if_exists: OnConflictBehavior | None = None,
name: str | None = None,
headers: Mapping[str, str] | None = None,
description: str | None = None,
params: QueryParamTypes | None = None
) -> Assistantclient = get_sync_client(url="http://localhost:2024")
assistant = client.assistants.create(
graph_id="agent",
context={"model_name": "openai"},
metadata={"number":1},
assistant_id="my-assistant-id",
if_exists="do_nothing",
name="my_name"
)| Name | Type | Description |
|---|---|---|
graph_id* | str | None | The ID of the graph the assistant should use. The graph ID is normally set in your langgraph.json configuration. |
config | Config | None | Default: NoneConfiguration to use for the graph. |
context | Context | None | Default: NoneStatic context to add to the assistant. |
metadata | Json | Default: NoneMetadata to add to assistant. |
assistant_id | str | None | Default: NoneAssistant ID to use, will default to a random UUID if not provided. |
if_exists | OnConflictBehavior | None | Default: NoneHow to handle duplicate creation. Defaults to 'raise' under the hood. Must be either 'raise' (raise error if duplicate), or 'do_nothing' (return existing assistant). |
name | str | None | Default: NoneThe name of the assistant. Defaults to 'Untitled' under the hood. |
headers | Mapping[str, str] | None | Default: NoneOptional custom headers to include with the request. |
description | str | None | Default: NoneOptional description of the assistant. The description field is available for langgraph-api server version>=0.0.45 |
params | QueryParamTypes | None | Default: NoneOptional query parameters to include with the request. |