Canonical reference for LangSmith environment variables and their mapping to API authentication headers.
Langstar uses three core environment variables for authentication across different LangSmith APIs:
LANGSMITH_API_KEY- API key for LangSmith and LangGraph servicesLANGSMITH_ORGANIZATION_ID- Organization ID for scoping operationsLANGSMITH_WORKSPACE_ID- Workspace ID for narrower scoping (also used as Tenant ID)
| Environment Variable | HTTP Header | Usage |
|---|---|---|
LANGSMITH_API_KEY |
X-Api-Key |
Required for most APIs |
LANGSMITH_ORGANIZATION_ID |
x-organization-id |
Optional scoping header for LangSmith API |
LANGSMITH_WORKSPACE_ID |
X-Tenant-Id |
Required for Control Plane API; optional scoping for LangSmith API |
Required:
LANGSMITH_API_KEY→X-Api-Keyheader
Optional (for scoping):
LANGSMITH_ORGANIZATION_ID→x-organization-idheaderLANGSMITH_WORKSPACE_ID→X-Tenant-Idheader
Notes:
- Both
x-organization-idandX-Tenant-Idcan be used together for workspace-scoped requests - When workspace ID is set, it provides narrower scoping than organization ID alone
- Scoping headers affect which resources are accessible (e.g., private prompts vs public prompts)
Required:
LANGSMITH_API_KEY→X-Api-KeyheaderLANGSMITH_WORKSPACE_ID→X-Tenant-Idheader
Documentation: https://api.host.langchain.com/docs
Notes:
- Both headers are required for all Control Plane API requests
- The
X-Tenant-Idheader uses the workspace ID value - This API manages LangGraph deployments, revisions, and integrations
Required:
LANGSMITH_API_KEY→X-Api-Keyheader
Notes:
- No scoping headers are used (assistants are deployment-level resources)
- The API key is tied to a specific deployment
- All operations are automatically scoped to that deployment
Required:
- Bearer token (different authentication method)
Notes:
- SCIM API uses
Authorization: Bearer <token>header - Not using the standard LangSmith environment variables
- Enterprise-only feature for user provisioning
Required:
LANGSMITH_API_KEY→X-Api-Keyheader
Notes:
- No scoping headers needed
- Used for ingesting traces, logs, and Claude Code telemetry
| API | Required Headers | Required Env Vars | Optional Env Vars |
|---|---|---|---|
| LangSmith API | X-Api-Key |
LANGSMITH_API_KEY |
LANGSMITH_ORGANIZATION_ID, LANGSMITH_WORKSPACE_ID |
| Control Plane API | X-Api-Key, X-Tenant-Id |
LANGSMITH_API_KEY, LANGSMITH_WORKSPACE_ID |
None |
| Agent Server API | X-Api-Key |
LANGSMITH_API_KEY |
None |
| SCIM API | Authorization: Bearer <token> |
(Different auth method) | N/A |
| OpenTelemetry | X-Api-Key |
LANGSMITH_API_KEY |
None |
Why all three variables are required for tests:
As documented in issue #660, silent skip patterns in tests led to requiring all three environment variables (LANGSMITH_API_KEY, LANGSMITH_ORGANIZATION_ID, LANGSMITH_WORKSPACE_ID) for all integration tests, even though individual tests may not need all three.
This approach was chosen because:
- It's simpler to explain than requiring different variables for different tests
- It ensures tests have all necessary credentials available
- It prevents silent test skips that create false confidence
For test writers:
- Always require all three variables explicitly using
.expect()(no silent skips) - See
docs/dev/testing/HIGH_LEVEL_TESTING_GUIDELINES.mdfor testing standards - Reference
docs/dev/testing/test-fixtures.mdfor test deployment setup
export LANGSMITH_API_KEY="<your-api-key>"export LANGSMITH_API_KEY="<your-api-key>"
export LANGSMITH_ORGANIZATION_ID="<your-org-id>"export LANGSMITH_API_KEY="<your-api-key>"
export LANGSMITH_ORGANIZATION_ID="<your-org-id>"
export LANGSMITH_WORKSPACE_ID="<your-workspace-id>"export LANGSMITH_API_KEY="<your-api-key>"
export LANGSMITH_WORKSPACE_ID="<your-workspace-id>" # Required!export LANGSMITH_API_KEY="<your-api-key>"
export LANGSMITH_ORGANIZATION_ID="<your-org-id>"
export LANGSMITH_WORKSPACE_ID="<your-workspace-id>"The mapping is implemented in:
sdk/src/auth.rs-AuthConfigstruct that loads environment variablessdk/src/client.rs- HTTP client methods that add headers based onAuthConfig
Key implementation notes:
LANGSMITH_WORKSPACE_IDmaps toX-Tenant-Idheader (workspace ID = tenant ID)- Control Plane API methods require
workspace_idto be set (seecontrol_plane_*methods) - LangSmith API methods optionally add scoping headers if set (see
langsmith_*methods) - LangGraph API methods do not add scoping headers (deployment-level resources)
reference/api-specs/LANGSMITH_APIS_DETAILS.md- Complete API specifications catalogreference/api-specs/LANGSMITH_API_OVERVIEW.md- Quick API overviewdocs/dev/testing/HIGH_LEVEL_TESTING_GUIDELINES.md- Testing standards and requirementsdocs/dev/testing/test-fixtures.md- Test deployment setupdocs/dev/testing/debugging-tests.md- Troubleshooting test failures- Issue #660 - Context on why all three variables are required for tests