> ## Documentation Index
> Fetch the complete documentation index at: https://agent-observability-docs.splunk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> An overview of the Splunk Agent Observability SDKs

The Splunk Agent Observability SDK provides a comprehensive set of tools for logging, evaluating, and experimenting with LLM applications. Regardless of how you go about logging your AI application, you will still need to install the Splunk Agent Observability SDK and initialize your API keys by following the steps below.

<CardGroup cols={1}>
  <Card title="Python SDK" icon="python" horizontal href="https://pypi.org/project/splunk-ao">
    The Splunk Agent Observability Python SDK on PyPI.
  </Card>
</CardGroup>

## Installation

<CodeGroup>
  ```bash Pip theme={null}
  pip install splunk-ao
  ```

  ```bash uv theme={null}
  uv pip install splunk-ao
  ```

  ```bash Poetry theme={null}
  poetry add splunk-ao
  ```

  <SnippetInstallationNpm />

  <SnippetInstallationYarn />

  <SnippetInstallationPnpm />
</CodeGroup>

If you want to use the OpenAI wrapper in Python, you need to install with the optional OpenAI dependencies.

<CodeGroup>
  ```bash Pip theme={null}
  pip install "splunk-ao[openai]"
  ```

  ```bash uv theme={null}
  uv pip install "splunk-ao[openai]"
  ```

  ```bash Poetry theme={null}
  poetry add "splunk-ao[openai]"
  ```
</CodeGroup>

## Initialization and authentication

If you are using an on-premises, standalone, or custom deployment, you need a [Splunk Agent Observability API key](/references/faqs/find-keys#splunk-ao-api-key) set as an environment variable called `SPLUNK_AO_API_KEY`. The Splunk Agent Observability SDK will automatically pick this up from the environment variable at run time.

You can also optionally set the following environment variables to define the project, Agent Stream, and URL that Splunk Agent Observability should use.

| Environment variable     | Description                                                                                                                                                                             |
| :----------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SPLUNK_AO_PROJECT`      | The [Splunk Agent Observability project](/concepts/projects) to log to. If this is not set, you will need to pass the project name in code.                                             |
| `SPLUNK_AO_AGENT_STREAM` | The [default Agent Stream](/sdk-api/logging/logging-basics) to log to. If this is not set, you will need to pass the Agent Stream name in code.                                         |
| `SPLUNK_AO_CONSOLE_URL`  | Only required for on-premises, standalone, and custom deployments. Set this to the URL of your deployment. The URL appears in the browser when you log into Splunk Agent Observability. |

<Note>
  If you are using the free version of Splunk Agent Observability, there is no need to set the `SPLUNK_AO_CONSOLE_URL` environment variable.
</Note>

When developing your application, you should use a `.env` file. Create or update a `.env` file with the following values as required:

<CodeGroup>
  ```ini .env theme={null}
  # Provide your Splunk Agent Observability
  # API key and URL if you are using an
  # on-premises, standalone, or custom deployment
  # SPLUNK_AO_API_KEY="your-splunk-ao-api-key"
  # SPLUNK_AO_CONSOLE_URL="your-splunk-ao-url"

  # Your Splunk Agent Observability project name
  SPLUNK_AO_PROJECT="your-splunk-ao-project-name"

  # The name of the Agent Stream you want to use for logging
  SPLUNK_AO_AGENT_STREAM="your-splunk-ao-agent-stream"
  ```
</CodeGroup>

You can then load the environment variables from this file:

<CodeGroup>
  ```python Python theme={null}
  from dotenv import load_dotenv
  load_dotenv()
  ```
</CodeGroup>

For Python, you will need to install `python-dotenv` if you haven't already.

<CodeGroup>
  ```bash Pip theme={null}
  pip install python-dotenv
  ```

  ```bash uv theme={null}
  uv pip install python-dotenv
  ```

  ```bash Poetry theme={null}
  poetry add python-dotenv
  ```
</CodeGroup>

## Logging

The Splunk Agent Observability SDKs allow you to log all prompts, responses, and statistics around your LLM usage. There are three main ways to log your application:

1. **Use a third-party integration** - use wrappers that integrate with common SDKs to automatically log LLM calls or agentic workflows.
2. **Use a decorator** - by decorating a function that calls an LLM with the `@log` decorator or `log` wrapper, the Splunk Agent Observability SDK logs all AI prompts within.
3. **Directly using the `SplunkAOLogger` class** - For more control over your logging, you can use the `SplunkAOLogger` directly. This allows you to manually create sessions, start traces, and log spans. This can be mixed with the other methods, for example accessing the logger directly inside a decorated function call to manually add spans.

### Log experiments

Experiments are logged automatically when they are run, but you can use these same SDK concepts inside the code being run by your experiment for greater control and additional logging. This allows you to not only create distinct experiments, such as in notebooks, but to also add experiments to your production application code.

See our [run experiments with code documentation](/sdk-api/experiments/running-experiments) for more details.

## Next steps

### Logging with the SDKs

<CardGroup cols={2}>
  <Card title="Learn how to log experiments" icon="flask" horizontal href="/sdk-api/experiments">
    Learn how to run experiments with multiple data points using datasets and prompt templates
  </Card>

  <Card title="Splunk Agent Observability logger" icon="code" horizontal href="/sdk-api/logging/splunk-ao-logger">
    Log with full control over sessions, traces, and spans using the Splunk Agent Observability logger.
  </Card>

  <Card title="Log decorator" icon="code" horizontal href="/sdk-api/logging/log-decorator/log-decorator">
    Quickly add logging to your code with the log decorator and wrapper.
  </Card>

  <Card title="Splunk Agent Observability context" icon="code" horizontal href="/sdk-api/logging/splunk-ao-context">
    Manage logging using the Splunk Agent Observability context manager.
  </Card>
</CardGroup>

### How-to guides

<CardGroup cols={2}>
  <Card title="Log Using the OpenAI Wrapper" href="/how-to-guides/basics/basic-example" horizontal>
    Learn how to integrate and use OpenAI's API with Splunk Agent Observability's wrapper client.

    <br />

    **Python**
  </Card>

  <Card title="Log Using the @log Decorator" href="/how-to-guides/basics/basic-logging-with-decorator/basic-logging-with-decorator" horizontal>
    Learn how to use the Splunk Agent Observability @log decorator to log functions to traces

    <br />

    **Python**
  </Card>

  <Card title="Create Traces and Spans" href="/how-to-guides/basics/manual-span-creation/manual-span-creation" horizontal>
    Learn how to create log traces and spans manually in your AI apps

    <br />

    **Python**
  </Card>
</CardGroup>

### SDK reference

<CardGroup cols={1}>
  <Card title="Python SDK Reference" icon="python" horizontal href="/sdk-api/python/sdk-reference">
    The Splunk Agent Observability Python SDK reference.
  </Card>
</CardGroup>
