Skip to main content
The official LangSmith Terraform provider lets you manage LangSmith organization and workspace resources as code: workspaces, custom roles, organization and workspace members, resource tags, access policies, evaluators, run rules, and alert rules. It is the infrastructure-as-code counterpart to managing your organization using the API.
Managing resource tags and access policies requires LangSmith Terraform provider v0.0.6 or later.
Before diving in, it might be helpful to read:

Install and configure

Add the provider to your Terraform configuration and pin a version:
Then run terraform init to download the provider.

Authentication

The provider resolves credentials the same way as the LangSmith SDK and CLI. Prefer environment variables or a profile over hardcoding api_key:
  • EnvironmentLANGSMITH_API_KEY, LANGSMITH_ENDPOINT (API URL), LANGSMITH_WORKSPACE_ID.
  • Profile—set profile (or LANGSMITH_PROFILE) to use a LangSmith CLI profile.
  • Provider argumentsapi_key, api_url, workspace_id, profile.
Create an API key or service key in your LangSmith settings. See Authentication methods for the available key types.
Organization-scoped operations, like creating workspaces, inviting organization members, and managing access policies, require an organization-scoped service key with Organization Admin permissions. Set workspace_id (or LANGSMITH_WORKSPACE_ID) to target workspace-scoped resources such as workspace memberships, resource tags, evaluators, and run rules.

Examples

Create a workspace

Manage roles and members

Look up built-in roles with data sources, then assign them. This invites a user to the organization and grants them admin on the workspace:
You can also define a custom workspace role, for example by cloning an existing role’s permissions:

Manage resource tags and access policies

Use resource tags to organize workspace resources and apply attribute-based access control (ABAC). The langsmith_tag convenience resource owns one tag key and one value. Use the independent langsmith_tag_key and langsmith_tag_value resources when keys or values are shared across configurations. The following configuration creates an Environment=production tag, applies it to a tracing project, and limits a workspace role to production projects:

Automate evaluators, run rules, and alerts

The provider manages more than accounts. You can codify online code evaluators, the run rules that apply them, and alerts alongside your workspaces:

Resource reference

The full list of resources and data sources—with every argument and attribute—is published and kept in sync on the Terraform Registry:

LangSmith provider on the Terraform Registry

Browse the complete reference for all resources and data sources.