LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
  • RemoteGraph
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDKRemoteGraph
Language
Theme
PythonlangsmithclientClientcreate_run
Method●Since v0.0

create_run

Persist a run to the LangSmith API.

Copy
create_run(
  self,
  name: str,
  inputs: dict[str, Any],
  run_type: RUN_TYPE_T,
  *,
  project_name: Optional[str] = None,
  revision_id: Optional[str] = None,
  dangerously_allow_filesystem: bool = False,
  api_key: Optional[str] = None,
  api_url: Optional[str] = None,
  **kwargs: Any = {}
) -> None

Example:

from langsmith import Client
import datetime
from uuid import uuid4

client = Client()

run_id = uuid4()
client.create_run(
    id=run_id,
    project_name=project_name,
    name="test_run",
    run_type="llm",
    inputs={"prompt": "hello world"},
    outputs={"generation": "hi there"},
    start_time=datetime.datetime.now(datetime.timezone.utc),
    end_time=datetime.datetime.now(datetime.timezone.utc),
    hide_inputs=True,
    hide_outputs=True,
)

Parameters

NameTypeDescription
name*str

The name of the run.

inputs*Dict[str, Any]

The input values for the run.

run_type*str

The type of the run, such as tool, chain, llm, retriever, embedding, prompt, or parser.

project_nameOptional[str]
Default:None

The project name of the run.

revision_idOptional[Union[UUID, str]]
Default:None

The revision ID of the run.

api_keyOptional[str]
Default:None

The API key to use for this specific run.

api_urlOptional[str]
Default:None

The API URL to use for this specific run.

service_key*Optional[str]

The service JWT key for service-to-service auth.

tenant_id*Optional[str]

The tenant ID for multi-tenant requests.

authorization*Optional[str]

The Authorization header value.

cookie*Optional[str]

The Cookie header value.

**kwargsAny
Default:{}

Additional keyword arguments.

View source on GitHub