Module scenario.config.langwatch

Use LangWatch configuration in Scenario to link agent simulations with observability, evaluations, and AI agent testing.

This module provides configuration for LangWatch API integration, including endpoint URLs and authentication credentials.

Expand source code
"""
Use LangWatch configuration in Scenario to link agent simulations with observability, evaluations, and AI agent testing.

This module provides configuration for LangWatch API integration,
including endpoint URLs and authentication credentials.
"""

from pydantic import Field, HttpUrl
from pydantic_settings import BaseSettings, SettingsConfigDict


class LangWatchSettings(BaseSettings):
    """
    Configuration for LangWatch API integration.

    This class handles configuration for connecting to LangWatch services,
    automatically reading from environment variables with the LANGWATCH_ prefix.

    Attributes:
        endpoint: LangWatch API endpoint URL
        api_key: API key for LangWatch authentication
        project_id: Optional LangWatch project ID. When set, requests scope to
            this project via the X-Project-Id header. Required for API keys
            that are not bound to a single project.

    Environment Variables:
        LANGWATCH_ENDPOINT: LangWatch API endpoint (defaults to https://app.langwatch.ai)
        LANGWATCH_API_KEY: API key for authentication (defaults to empty string)
        LANGWATCH_PROJECT_ID: Project ID for project-scoped requests (defaults to empty string)

    Example:
        ```
        # Using environment variables
        # export LANGWATCH_ENDPOINT="https://app.langwatch.ai"
        # export LANGWATCH_API_KEY="your-api-key"
        # export LANGWATCH_PROJECT_ID="project_xxx"

        settings = LangWatchSettings()
        print(settings.endpoint)    # https://app.langwatch.ai
        print(settings.api_key)     # your-api-key
        print(settings.project_id)  # project_xxx

        # Or override programmatically
        settings = LangWatchSettings(
            endpoint="https://custom.langwatch.ai",
            api_key="your-api-key",
            project_id="project_xxx",
        )
        ```
    """

    model_config = SettingsConfigDict(env_prefix="LANGWATCH_", case_sensitive=False)

    endpoint: HttpUrl = Field(
        default=HttpUrl("https://app.langwatch.ai"),
        description="LangWatch API endpoint URL",
    )
    api_key: str = Field(default="", description="API key for LangWatch authentication")
    project_id: str = Field(
        default="",
        description="LangWatch project ID, sent as X-Project-Id when present",
    )

Classes

class LangWatchSettings (**values: Any)

Configuration for LangWatch API integration.

This class handles configuration for connecting to LangWatch services, automatically reading from environment variables with the LANGWATCH_ prefix.

Attributes

endpoint
LangWatch API endpoint URL
api_key
API key for LangWatch authentication
project_id
Optional LangWatch project ID. When set, requests scope to this project via the X-Project-Id header. Required for API keys that are not bound to a single project.

Environment Variables: LANGWATCH_ENDPOINT: LangWatch API endpoint (defaults to https://app.langwatch.ai) LANGWATCH_API_KEY: API key for authentication (defaults to empty string) LANGWATCH_PROJECT_ID: Project ID for project-scoped requests (defaults to empty string)

Example

# Using environment variables
# export LANGWATCH_ENDPOINT="https://app.langwatch.ai"
# export LANGWATCH_API_KEY="your-api-key"
# export LANGWATCH_PROJECT_ID="project_xxx"

settings = LangWatchSettings()
print(settings.endpoint)    # <https://app.langwatch.ai>
print(settings.api_key)     # your-api-key
print(settings.project_id)  # project_xxx

# Or override programmatically
settings = LangWatchSettings(
    endpoint="https://custom.langwatch.ai",
    api_key="your-api-key",
    project_id="project_xxx",
)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class LangWatchSettings(BaseSettings):
    """
    Configuration for LangWatch API integration.

    This class handles configuration for connecting to LangWatch services,
    automatically reading from environment variables with the LANGWATCH_ prefix.

    Attributes:
        endpoint: LangWatch API endpoint URL
        api_key: API key for LangWatch authentication
        project_id: Optional LangWatch project ID. When set, requests scope to
            this project via the X-Project-Id header. Required for API keys
            that are not bound to a single project.

    Environment Variables:
        LANGWATCH_ENDPOINT: LangWatch API endpoint (defaults to https://app.langwatch.ai)
        LANGWATCH_API_KEY: API key for authentication (defaults to empty string)
        LANGWATCH_PROJECT_ID: Project ID for project-scoped requests (defaults to empty string)

    Example:
        ```
        # Using environment variables
        # export LANGWATCH_ENDPOINT="https://app.langwatch.ai"
        # export LANGWATCH_API_KEY="your-api-key"
        # export LANGWATCH_PROJECT_ID="project_xxx"

        settings = LangWatchSettings()
        print(settings.endpoint)    # https://app.langwatch.ai
        print(settings.api_key)     # your-api-key
        print(settings.project_id)  # project_xxx

        # Or override programmatically
        settings = LangWatchSettings(
            endpoint="https://custom.langwatch.ai",
            api_key="your-api-key",
            project_id="project_xxx",
        )
        ```
    """

    model_config = SettingsConfigDict(env_prefix="LANGWATCH_", case_sensitive=False)

    endpoint: HttpUrl = Field(
        default=HttpUrl("https://app.langwatch.ai"),
        description="LangWatch API endpoint URL",
    )
    api_key: str = Field(default="", description="API key for LangWatch authentication")
    project_id: str = Field(
        default="",
        description="LangWatch project ID, sent as X-Project-Id when present",
    )

Ancestors

  • pydantic_settings.main.BaseSettings
  • pydantic.main.BaseModel

Class variables

var api_key : str
var endpoint : pydantic.networks.HttpUrl
var model_config : ClassVar[pydantic_settings.main.SettingsConfigDict]
var project_id : str