Persist a run to the LangSmith API.
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 = {}
) -> NoneExample:
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,
)| Name | Type | Description |
|---|---|---|
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_name | Optional[str] | Default: NoneThe project name of the run. |
revision_id | Optional[Union[UUID, str]] | Default: NoneThe revision ID of the run. |
api_key | Optional[str] | Default: NoneThe API key to use for this specific run. |
api_url | Optional[str] | Default: NoneThe 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. |
**kwargs | Any | Default: {}Additional keyword arguments. |