LangSmith SDK profiles let you keep API keys, endpoints, and workspace IDs in a reusable JSON file instead of setting the same environment variables in every shell session. Use profiles when you switch between LangSmith Cloud regions, self-hosted instances, or workspaces often, or when you want a remote runtime to load the same SDK configuration from a mounted file.Documentation Index
Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
Use this file to discover all available pages before exploring further.
Minimum versions
Profile support is available in the following releases:| Tool or SDK | Minimum version |
|---|---|
LangSmith CLI profile commands and langsmith login | v0.2.26 |
| Go SDK | v0.7.0 |
| Python SDK | v0.8.1 |
| TypeScript SDK | v0.6.1 |
| Java SDK | v0.1.0-beta.3 |
Profile file location
By default, SDKs look for a profile file at:LANGSMITH_CONFIG_FILE:
Create a profile file
Create~/.langsmith/config.json with a profiles object. Each profile can define:
| Field | Description |
|---|---|
api_url | LangSmith API endpoint. Use the same value you would use for LANGSMITH_ENDPOINT. |
api_key | LangSmith API key. See Create an account and API key. |
workspace_id | Workspace ID. Required when the API key can access multiple workspaces. |
oauth | OAuth token metadata created by LangSmith tooling. |
Select a profile
SDKs select profiles in this order:LANGSMITH_PROFILE, if set.current_profilein the profile file, if set.- A profile named
default, if present.
--profile flag, which takes precedence over LANGSMITH_PROFILE for that command:
Manage profiles with the CLI
Use the LangSmith CLI to create, inspect, switch, and delete profiles without editing the JSON file by hand. To create an API-key profile from an existing API key:| Command | Description |
|---|---|
langsmith profile list | List saved profiles. Alias: langsmith profile ls. |
langsmith profile show <name> | Show a saved profile. Secret values are redacted in output. |
langsmith profile use <name> | Set current_profile in the profile file. |
langsmith profile set-workspace <workspace-id> | Set the default workspace for the selected profile. |
langsmith profile delete <name> | Delete a saved profile. |
--format pretty for human-readable tables:
Authenticate with langsmith login
Run langsmith login to authenticate with OAuth instead of manually creating an API-key profile. The command starts a browser-based device authorization flow, stores OAuth tokens in the selected profile, and sets that profile as current.
langsmith login currently supports LangSmith Cloud (SaaS) only. For self-hosted or other non-SaaS LangSmith endpoints, create an API-key profile instead.--profile or LANGSMITH_PROFILE:
langsmith login chooses the profile name in this order:
--profile, if passed.LANGSMITH_PROFILE, if set.current_profilein the profile file, if set.default.
--api-url, if passed.LANGSMITH_ENDPOINT, if set.- The selected profile’s
api_url, if present. - The default LangSmith Cloud endpoint.
Override profile values
Explicit client constructor arguments and environment variables take precedence over profile values.| Setting | Precedence |
|---|---|
| Endpoint | Constructor api_url or apiUrl, then LANGSMITH_ENDPOINT, then profile api_url, then the default LangSmith Cloud endpoint. |
| Authentication | Constructor API key, then LANGSMITH_API_KEY, then profile OAuth access token, then profile api_key. |
| Workspace | Constructor workspace_id or workspaceId, then LANGSMITH_WORKSPACE_ID, then profile workspace_id. |
LANGCHAIN_API_KEY, LANGCHAIN_ENDPOINT, and LANGCHAIN_WORKSPACE_ID aliases still work, but prefer the LANGSMITH_* names for new configuration.
If a profile contains both oauth.access_token and api_key, SDKs use the OAuth access token first. If an OAuth refresh token is present and the access token is expired or close to expiring, SDKs can refresh the token and write the updated token fields back to the profile file.
If you mount a profile file as read-only, OAuth token refresh cannot persist updated tokens. Read-only mounts are appropriate for API-key profiles. Use a writable mount only when you intentionally rely on OAuth token refresh.
Use profiles in code
When the profile file is present, create the client normally:Mount profiles in remote runtimes
For remote runtimes, mount the profile file as a secret file and setLANGSMITH_CONFIG_FILE to the mounted path. Do not copy the file into the image or repository.
Docker
Mount your local profile directory into the container:Kubernetes
Create a Kubernetes secret from the profile file:Remote development and CI
In remote development environments or CI jobs, store the profile JSON in the platform’s secret store, write it to a temporary file at runtime, and setLANGSMITH_CONFIG_FILE to that file path.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

