LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdk_syncthreadsSyncThreadsClientcreate
    Method●Since v0.3

    create

    Copy
    create(
      self,
      *,
      metadata: Json = None,
      thread_id: str | None
    View source on GitHub
    =
    None
    ,
    if_exists
    :
    OnConflictBehavior
    |
    None
    =
    None
    ,
    supersteps
    :
    Sequence
    [
    dict
    [
    str
    ,
    Sequence
    [
    dict
    [
    str
    ,
    Any
    ]
    ]
    ]
    ]
    |
    None
    =
    None
    ,
    graph_id
    :
    str
    |
    None
    =
    None
    ,
    ttl
    :
    int
    |
    Mapping
    [
    str
    ,
    Any
    ]
    |
    None
    =
    None
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    params
    :
    QueryParamTypes
    |
    None
    =
    None
    )
    ->
    Thread

    Parameters

    NameTypeDescription
    metadataJson
    Default:None

    Metadata to add to thread.

    thread_idstr | None
    Default:None

    ID of thread. If None, ID will be a randomly generated UUID.

    if_existsOnConflictBehavior | None
    Default:None
    superstepsSequence[dict[str, Sequence[dict[str, Any]]]] | None
    Default:None
    graph_idstr | None
    Default:None
    ttlint | Mapping[str, Any] | None
    Default:None
    headersMapping[str, str] | None
    Default:None

    Create a new thread.

    client = get_sync_client(url="http://localhost:2024")
    thread = client.threads.create(
        metadata={"number":1},
        thread_id="my-thread-id",
        if_exists="raise"
    )

    )

    How to handle duplicate creation. Defaults to 'raise' under the hood. Must be either 'raise' (raise error if duplicate), or 'do_nothing' (return existing thread).

    Apply a list of supersteps when creating a thread, each containing a sequence of updates. Each update has values or command and as_node. Used for copying a thread between deployments.

    Optional graph ID to associate with the thread.

    Optional time-to-live in minutes for the thread. You can pass an integer (minutes) or a mapping with keys ttl and optional strategy (defaults to "delete").

    Optional custom headers to include with the request.