LangSmith provides a collaborative interface to create, test, and iterate on prompts. While you can dynamically fetch prompts from LangSmith into your application at runtime, you may prefer to sync prompts with your own database or version control system. To support this workflow, LangSmith allows you to receive notifications of prompt updates via webhooks. Why sync prompts with GitHub?
  • Version Control: Keep your prompts versioned alongside your application code in a familiar system.
  • CI/CD Integration: Trigger automated staging or production deployments when critical prompts change.
Prompt Webhook Diagram

Prerequisites

Before we begin, ensure you have the following set up:
  1. GitHub Account: A standard GitHub account.
  2. GitHub Repository: Create a new (or choose an existing) repository where your LangSmith prompt manifests will be stored. This could be the same repository as your application code or a dedicated one for prompts.
  3. GitHub Personal Access Token (PAT):
    • LangSmith webhooks don’t directly interact with GitHub—they call an intermediary server that you create.
    • This server requires a GitHub PAT to authenticate and make commits to your repository.
    • Must include the repo scope (public_repo is sufficient for public repositories).
    • Go to GitHub > Settings > Developer settings > Personal access tokens > Tokens (classic).
    • Click Generate new token (classic).
    • Name it (e.g., “LangSmith Prompt Sync”), set an expiration, and select the required scopes.
    • Click Generate token and copy it immediately — it won’t be shown again.
    • Store the token securely and provide it as an environment variable to your server.

Understanding LangSmith “Prompt Commits” and Webhooks

In LangSmith, when you save changes to a prompt, you’re essentially creating a new version or a “Prompt Commit.” These commits are what can trigger webhooks. The webhook will send a JSON payload containing the new prompt manifest.
It’s important to understand that LangSmith webhooks for prompt commits are generally triggered at the workspace level. This means if any prompt within your LangSmith workspace is modified and a “prompt commit” is saved, the webhook will fire and send the updated manifest of the prompt. The payloads are identifiable by prompt id. Your receiving server should be designed with this in mind.

Implementing a FastAPI Server for Webhook Reception

To effectively process webhook notifications from LangSmith when prompts are updated, an intermediary server application is necessary. This server will act as the receiver for HTTP POST requests sent by LangSmith. For demonstration purposes in this guide, we will outline the creation of a simple FastAPI application to fulfill this role. This publicly accessible server will be responsible for:
  1. Receiving Webhook Requests: Listening for incoming HTTP POST requests.
  2. Parsing Payloads: Extracting and interpreting the JSON-formatted prompt manifest from the request body.
  3. Committing to GitHub: Programmatically creating a new commit in your specified GitHub repository, containing the updated prompt manifest. This ensures your prompts remain version-controlled and synchronized with changes made in LangSmith.
For deployment, platforms like Render.com (offering a suitable free tier), Vercel, Fly.io, or other cloud providers (AWS, GCP, Azure) can be utilized to host the FastAPI application and obtain a public URL. The server’s core functionality will include an endpoint for webhook reception, logic for parsing the manifest, and integration with the GitHub API (using a Personal Access Token for authentication) to manage commits.

Configuring the Webhook in LangSmith

Once your FastAPI server is deployed and you have its public URL, you can configure the webhook in LangSmith:
  1. Navigate to your LangSmith workspace.
  2. Go to the Prompts section. Here you’ll see a list of your prompts. LangSmith Prompts section
  3. On the top right of the Prompts page, click the + Webhook button.
  4. You’ll be presented with a form to configure your webhook: LangSmith Webhook configuration modal
    • Webhook URL: Enter the full public URL of your deployed FastAPI server’s endpoint. For our example server, this would be https://prompt-commit-webhook.onrender.com/webhook/commit.
    • Headers (Optional):
      • You can add custom headers that LangSmith will send with each webhook request.
  5. Test the Webhook: LangSmith provides a “Send Test Notification” button. Use this to send a sample payload to your server. Check your server logs (e.g., on Render) to ensure it receives the request and processes it successfully (or to debug any issues).
  6. Save the webhook configuration.

The Workflow in Action

Workflow Diagram showing: User saves prompt in LangSmith, LangSmith sends webhook to FastAPI Server, which interacts with GitHub to update files Now, with everything set up, here’s what happens:
  1. Prompt Modification: A user (developer or non-technical team member) modifies a prompt in the LangSmith UI and saves it, creating a new “prompt commit.”
  2. Webhook Trigger: LangSmith detects this new prompt commit and triggers the configured webhook.
  3. HTTP Request: LangSmith sends an HTTP POST request to the public URL of your FastAPI server (e.g., https://prompt-commit-webhook.onrender.com/webhook/commit). The body of this request contains the JSON prompt manifest for the entire workspace.
  4. Server Receives Payload: Your FastAPI server’s endpoint receives the request.
  5. GitHub Commit: The server parses the JSON manifest from the request body. It then uses the configured GitHub Personal Access Token, repository owner, repository name, file path, and branch to:
    • Check if the manifest file already exists in the repository on the specified branch to get its SHA (this is necessary for updating an existing file).
    • Create a new commit with the latest prompt manifest, either creating the file or updating it if it already exists. The commit message will indicate that it’s an update from LangSmith.
  6. Confirmation: You should see the new commit appear in your GitHub repository. Manifest commited to Github
You’ve now successfully synced your LangSmith prompts with GitHub!

Beyond a Simple Commit

Our example FastAPI server performs a direct commit of the entire prompt manifest. However, this is just the starting point. You can extend the server’s functionality to perform more sophisticated actions:
  • Granular Commits: Parse the manifest and commit changes to individual prompt files if you prefer a more granular structure in your repository.
  • Trigger CI/CD: Instead of (or in addition to) committing, have the server trigger a CI/CD pipeline (e.g., Jenkins, GitHub Actions, GitLab CI) to deploy a staging environment, run tests, or build new application versions.
  • Update Databases/Caches: If your application loads prompts from a database or cache, update these stores directly.
  • Notifications: Send notifications to Slack, email, or other communication channels about prompt changes.
  • Selective Processing: Based on metadata within the LangSmith payload (if available, e.g., which specific prompt changed or by whom), you could apply different logic.