High severity HTTP 404 beginner · Fix: 2-5 min

LangSmithProjectNotFoundError

langsmith.errors.LangSmithProjectNotFoundError

What this error means
LangSmith API returns a project not found error when the specified project ID does not exist or is inaccessible with the current credentials.

Stack trace

traceback
langsmith.errors.LangSmithProjectNotFoundError: Project with ID 'abc123' not found or inaccessible.
  at langsmith.client.Client.get_project(Client.py:45)
  at user_code.py:12
QUICK FIX
Set the correct LANGSMITH_PROJECT_ID environment variable matching an existing project accessible by your API key.

Why it happens

This error occurs because the LangSmith client attempts to access a project ID that either does not exist, was deleted, or the API key used lacks permission to access it. It can also happen if the project ID is mistyped or missing from environment variables.

Detection

Catch LangSmithProjectNotFoundError exceptions when calling project-related methods and log the project ID and API key context to detect missing or unauthorized projects before crashing.

Causes & fixes

1

Incorrect or missing project ID in environment variables or code

✓ Fix

Verify and set the correct LANGSMITH_PROJECT_ID environment variable or pass the correct project ID explicitly to the client.

2

API key lacks permission to access the specified project

✓ Fix

Ensure the API key used has the necessary permissions for the project or use an API key associated with the correct account.

3

The project was deleted or never created in LangSmith

✓ Fix

Create the project in the LangSmith dashboard or use an existing valid project ID.

Code: broken vs fixed

Broken - triggers the error
python
import os
from langsmith import Client

client = Client(api_key=os.environ.get('LANGSMITH_API_KEY'))
project = client.get_project(os.environ.get('LANGSMITH_PROJECT_ID'))  # Raises LangSmithProjectNotFoundError
print(project)
Fixed - works correctly
python
import os
from langsmith import Client

# Ensure environment variables are set correctly
client = Client(api_key=os.environ.get('LANGSMITH_API_KEY'))
project_id = os.environ.get('LANGSMITH_PROJECT_ID')
if not project_id:
    raise ValueError('LANGSMITH_PROJECT_ID environment variable is not set')
project = client.get_project(project_id)  # Fixed: valid project ID
print(project)
Added explicit check for LANGSMITH_PROJECT_ID environment variable and ensured the client uses a valid project ID to avoid the not found error.

Workaround

Wrap the get_project call in try/except LangSmithProjectNotFoundError, then prompt the user to verify the project ID or fallback to a default project if available.

Prevention

Use environment validation on startup to confirm the project ID exists and the API key has access, and implement monitoring to alert on 404 project errors before runtime failures.

Python 3.9+ · langsmith >=0.1.0 · tested on 0.2.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.