# SDK Setup

Use SDK Setup when you are instrumenting an application directly with Revenium SDKs, middleware, API keys, and integration identifiers. Start here if you are adding metering to code you own.

## What You Need

* A Revenium API key with the right scope for your integration.
* Your tenant, team, and environment identifiers.
* The API base URL for your workspace.
* A choice of integration path: SDK, middleware, OTLP, MCP, Revvy CLI, or direct API.

## Recommended Next Steps

1. Review [API Key Permissions](/integrations/api-key-permissions.md) before creating production keys.
2. Choose an implementation path from [Integration Options](/integrations/integrations.md).
3. Use [Provider Integrations](/integrations/provider-integrations.md) for billing-provider account connections.
4. Use [OTLP Integration](/integrations/otlp-integration.md) if your stack already emits OpenTelemetry.

## <i class="fa-python">:python:</i> Python SDK

Install only the providers you need:

| Provider                           | Install command                                        |
| ---------------------------------- | ------------------------------------------------------ |
| OpenAI or Azure OpenAI             | `pip install "revenium-python-sdk[openai]"`            |
| Anthropic or Anthropic via Bedrock | `pip install "revenium-python-sdk[anthropic]"`         |
| Google Gemini                      | `pip install "revenium-python-sdk[google-genai]"`      |
| Google Vertex AI                   | `pip install "revenium-python-sdk[google-vertex]"`     |
| LiteLLM                            | `pip install "revenium-python-sdk[litellm]"`           |
| LiteLLM Proxy                      | `pip install "revenium-python-sdk[litellm-proxy]"`     |
| Ollama                             | `pip install "revenium-python-sdk[ollama]"`            |
| Perplexity                         | `pip install "revenium-python-sdk[perplexity-openai]"` |
| Fal.ai                             | `pip install "revenium-python-sdk[fal]"`               |
| LangChain                          | `pip install "revenium-python-sdk[langchain]"`         |

You can install multiple extras together, for example:

```bash
pip install "revenium-python-sdk[openai,anthropic,langchain]"
```

## <i class="fa-node">:node:</i> Node.js Middleware

Use the unified middleware package and provider sub-paths:

| Provider              | Package                              |
| --------------------- | ------------------------------------ |
| OpenAI / Azure OpenAI | `@revenium/middleware/openai`        |
| Anthropic             | `@revenium/middleware/anthropic`     |
| Google Vertex AI      | `@revenium/middleware/google/vertex` |
| Google AI SDK         | `@revenium/middleware/google/genai`  |
| Perplexity            | `@revenium/middleware/perplexity`    |
| LiteLLM               | `@revenium/middleware/litellm`       |

Install from npm:

```bash
npm install @revenium/middleware
```

## <i class="fa-golang">:golang:</i> Go SDK

Install:

```bash
go get github.com/revenium/revenium-go-sdk
```

Minimal OpenAI wrapper:

```go
import (
    "os"

    "github.com/revenium/revenium-go-sdk/openai"
    openai_sdk "github.com/openai/openai-go"
)

client := openai.Wrap(openai_sdk.NewClient(), openai.Config{
    APIKey: os.Getenv("REVENIUM_API_KEY"),
})
```

## Frameworks and Agent Tooling

| Framework or tool                                          | Start here                                                                                                                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| LangChain                                                  | Use the Python `langchain` extra, or use [OTLP Integration](/integrations/otlp-integration.md) if your app already emits OpenTelemetry.                                        |
| n8n                                                        | Use the Revenium n8n middleware packages for OpenAI or Anthropic agents.                                                                                                       |
| OpenInference / OpenLLMetry                                | Use [OTLP Integration](/integrations/otlp-integration.md).                                                                                                                     |
| Claude Code, Gemini CLI, Cursor, and other AI coding tools | Use [Context7 and AI Docs Access](/integrations/context7.md), [MCP Server](/integrations/mcp-server.md), or [Revvy CLI](/integrations/revvy-cli.md) depending on the workflow. |
| JetBrains IDEs (IntelliJ, PyCharm, GoLand, etc.)           | Use [Revvy CLI](/integrations/revvy-cli.md) for guided instrumentation — scans your codebase, finds AI call sites, and walks through SDK setup.                                |

## Usage Metadata

SDKs accept optional usage metadata for billing, attribution, and alerting. The fields accepted on `POST /meter/v2/ai/completions` are:

| Field                  | Purpose                                                                                              |
| ---------------------- | ---------------------------------------------------------------------------------------------------- |
| `organizationName`     | Top-level customer account. Accepts `organizationId` as an alias.                                    |
| `productName`          | Commercial tier or SKU. Accepts `productId` as an alias.                                             |
| `subscriber`           | Object: `{ id, email, credential: { name, value } }` — the end customer plus their specific API key. |
| `agent`                | Agent name making the call; powers per-agent cost views and the Tool Registry.                       |
| `traceId`              | Links sequential AI calls into a single execution path for Trace Analytics.                          |
| `taskType`             | Categorises the work the agent was doing (qualification, support, code review, etc.).                |
| `subscriptionId`       | The Revenium subscription this call rates against.                                                   |
| `responseQualityScore` | `0.0–1.0` evaluation score from RAGAS, LLM-as-judge, human review, or other quality signals.         |

At minimum, pass `organizationName` + `productName` + `subscriber.id`. Add `agent` and `traceId` to unlock agent-level cost views and Trace Analytics. The remaining fields are optional.

For OpenTelemetry attribution, see the `revenium.*` attributes in [OTLP Integration](/integrations/otlp-integration.md#deep-attribution-with-revenium-attributes).

## Related

* [API Reference](https://revenium.readme.io)
* [Revvy CLI](/integrations/revvy-cli.md)
* [Context7 and AI docs access](/integrations/context7.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.revenium.io/integrations/sdk-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
