Skip to main content
To get started with LangSmith, you need to create an account. You can sign up for a free account in the LangSmith UI. LangSmith supports sign in with Google, GitHub, and email.

API keys

LangSmith supports two types of API keys. You can use both types of token to authenticate requests to the LangSmith API, but they have different use cases: To log traces and run evaluations with LangSmith, create an API key to authenticate your requests.

Open API Keys settings

Navigate to the Settings page and select the API Keys section.

Configure the key type

For service keys, choose between an organization-scoped and workspace-scoped key. If the key is workspace-scoped, you must specify the workspaces.Enterprise users can also assign specific workspace roles to service keys, which adjusts their permissions independently of any user.

Set expiration

Set the key’s expiration. The key becomes unusable after the number of days chosen, or never, if that is selected.

Create the key

Click Create API Key. LangSmith will display the API key only once, so make sure to copy it and store it in a safe place.
Enterprise Organization Admins can edit the role on an existing service key without rotating the key. On the Settings page API Keys section, switch to the Service tab and click any service key row to open the edit dialog. Update the workspace role (and, for organization-scoped keys, the org role) and click Save. The key string itself is unchanged.

Deactivate or delete a personal access token

Deactivation temporarily stops a PAT from authenticating; deletion permanently removes it. Deactivate a token when you need to keep its record and reactivate it later. Members can deactivate, reactivate, and delete their own PATs. Organization Admins and Organization Operators can also manage every member’s PATs. Deactivation does not change a token’s expiration date, and Reactivate key is unavailable once that date has passed. Create a new token instead. To deactivate or delete a PAT:
  1. Go to Settings > API Keys and open the Personal tab.
  2. Find the token under My keys. To manage another member’s token, switch to All members.
  3. In the Actions column, select Deactivate key or Delete key. Each action opens its own confirmation dialog.
  4. Type the token’s description, which the dialog displays. For a token with no description, type the short key from the Key column instead.
  5. Select Deactivate or Delete to confirm. A success notification confirms the action.
To reactivate a deactivated PAT, select Reactivate key in the Actions column. Reactivation takes one click, without a confirmation dialog, and displays a success notification. Authentication results are cached, so a deactivated or deleted token stops working within a minute rather than instantly. A reactivated token may remain unusable until a cached rejection expires. Audit logs record deactivation as revoke_personal_access_token and reactivation as reinstate_personal_access_token. Service keys can only be deleted, not deactivated. Open the Service tab and select Delete key in the Actions column, then confirm with the typed description that deleting a PAT requires.

Configure the SDK

Install the SDK for your language:
For full details, refer to the Python SDK or JS/TS SDK reference. Then, set your API key and enable tracing:
You may also need the following additional environment variables:
  • LANGSMITH_ENDPOINT controls which LangSmith server the SDK sends data to. It defaults to https://api.smith.langchain.com (GCP US). Set it only if you are on a different deployment. For regional SaaS, set it to the API URL for your region:
    Region
    GCP US
    GCP EU
    GCP APAC
    AWS US
  • LANGSMITH_WORKSPACE_ID is required only if your API key is scoped to more than one workspace. Find your Workspace ID on the Settings page under General: LANGSMITH_WORKSPACE_ID=<Workspace ID>
To reuse endpoint, API key, and workspace settings across local shells or remote runtimes, refer to Profile configuration.

Use API keys outside of the SDK

See instructions for managing your organization via API.