> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://www.comet.com/docs/opik/quickstart/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://www.comet.com/_mcp/server. # Quickstart This guide helps you integrate the Opik platform with your existing Agent. The goal of this guide is to help you log your first traces and start tracking your prompts and agent configuration in Opik. ![Opik traces page showing trace details with span tree, outputs, and feedback scores](/docs/opik/_fern-img/509190201962bdf0a77fb8d701a1a9acd32dcc3522b3e1e885c4d2f537760905.webp) ## Prerequisites Before you begin, you'll need to choose how you want to use Opik: * **Opik Cloud**: Create a free account at [comet.com/opik](https://www.comet.com/signup?from=llm\&utm_source=opik\&utm_medium=colab\&utm_content=quickstart\&utm_campaign=opik) * **Self-hosting**: Follow the [self-hosting guide](/self-host/overview) to deploy Opik locally or on Kubernetes ## Logging your first LLM calls Opik makes it easy to integrate with your existing LLM application. Pick the tab that matches your stack and follow the three steps to log your first trace: #### Python SDK If you are using the Python function decorator, you can integrate by: Install the Opik Python SDK: ```bash pip install opik ``` Configure the Opik Python SDK: ```bash opik configure ``` Wrap your function with the `@track` decorator: ```python from opik import track @track def my_function(input: str) -> str: return input ``` All calls to the `my_function` will now be logged to Opik. This works well for any function even nested ones and is also supported by most integrations (just wrap any parent function with the `@track` decorator). #### TypeScript SDK If you want to use the TypeScript SDK to log traces directly: Install the Opik TypeScript SDK: ```bash npm install opik ``` Configure the Opik TypeScript SDK by running the interactive CLI tool: ```bash npx opik-ts configure ``` This will detect your project setup, install required dependencies, and help you configure environment variables. Log a trace using the Opik client: ```typescript import { Opik } from "opik"; const client = new Opik(); const trace = client.trace({ name: "My LLM Application", input: { prompt: "What is the capital of France?" }, output: { response: "The capital of France is Paris." }, }); trace.end(); await client.flush(); ``` All traces will now be logged to Opik. You can also log spans within traces for more detailed observability. #### OpenAI (Python) If you are using the OpenAI Python SDK, you can integrate by: Install the Opik Python SDK: ```bash pip install opik ``` Configure the Opik Python SDK, this will prompt you for your API key if you are using Opik Cloud or your Opik server address if you are self-hosting: ```bash opik configure ``` Wrap your OpenAI client with the `track_openai` function: ```python from opik.integrations.openai import track_openai from openai import OpenAI # Wrap your OpenAI client client = OpenAI() client = track_openai(client) # Use the client as normal completion = client.chat.completions.create( model="gpt-4o", messages=[ {"role": "user", "content": "Hello, how are you?", }, ], ) print(completion.choices[0].message.content) ``` All OpenAI calls made using the `client` will now be logged to Opik. You can combine this with the `@track` decorator to log the traces for each step of your agent. #### OpenAI (TS) If you are using the OpenAI TypeScript SDK, you can integrate by: Install the Opik TypeScript SDK: ```bash npm install opik-openai ``` Configure the Opik TypeScript SDK by running the interactive CLI tool: ```bash npx opik-ts configure ``` This will detect your project setup, install required dependencies, and help you configure environment variables. Wrap your OpenAI client with the `trackOpenAI` function: ```typescript import OpenAI from "openai"; import { trackOpenAI } from "opik-openai"; // Initialize the original OpenAI client const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, }); // Wrap the client with Opik tracking const trackedOpenAI = trackOpenAI(openai); // Use the tracked client just like the original const completion = await trackedOpenAI.chat.completions.create({ model: "gpt-4", messages: [{ role: "user", content: "Hello, how can you help me today?" }], }); console.log(completion.choices[0].message.content); // Ensure all traces are sent before your app terminates await trackedOpenAI.flush(); ``` All OpenAI calls made using the `trackedOpenAI` will now be logged to Opik. #### LangGraph If you are using LangGraph, you can integrate by: Install the Opik SDK: ```bash pip install opik ``` Configure the Opik SDK by running the `opik configure` command in your terminal: ```bash opik configure ``` Track your LangGraph graph with `track_langgraph`: ```python from opik.integrations.langchain import OpikTracer, track_langgraph # Create your LangGraph graph graph = ... app = graph.compile(...) # Create OpikTracer and track the graph once # The graph visualization is automatically extracted by track_langgraph opik_tracer = OpikTracer() app = track_langgraph(app, opik_tracer) # Now all invocations are automatically tracked! result = app.invoke({"messages": [HumanMessage(content = "How to use LangGraph ?")]}) ``` All LangGraph calls will now be logged to Opik. No need to pass callbacks on every invocation! #### AI integration If you already use a coding agent (Claude Code, Codex, Cursor, OpenCode, etc.), you can let it instrument your app for you with the Opik Skill. Requires Node.js installed. #### Install the Opik skill ```bash npx skills add comet-ml/opik-skills ``` #### Run the integration Once the skill is installed, you can integrate with Opik using the following prompt: ``` Instrument my agent with Opik using the /opik-instrument command. ``` #### All integrations Opik has **30+ integrations** with popular frameworks and model providers: #### [LangChain](/integrations/langchain) #### [LlamaIndex](/integrations/llama_index) #### [Anthropic](/integrations/anthropic) #### [AWS Bedrock](/integrations/bedrock) #### [Google Gemini](/integrations/gemini) #### [CrewAI](/integrations/crewai) **[View all 30+ integrations →](/integrations/overview)** ## Analyze your traces After running your application, you will start seeing your traces in Opik and you can use Ollie to analyze them and improve your agent. If you don't see traces appearing, reach out to us on [Slack](https://chat.comet.com) or raise an issue on [GitHub](https://github.com/comet-ml/opik/issues) and we'll help you troubleshoot. > **Tip** > > **Recommended if you build with an AI coding assistant.** Connect your assistant (Claude Code, > Codex, Cursor and more) to Opik and it can read these traces, score outputs and run evaluations > from chat, keeping observability where you are already working. One command, > `uvx opik mcp configure`, installs both the MCP server and the Opik skills and needs no SDK; > see [MCP server](/mcp-server). ## Next steps Now that you have logged your first traces, here's what to explore next: 1. [In depth guide on agent observability](/tracing/advanced/log_traces): Learn how to customize the data that is logged to Opik and how to log conversations. 2. [Opik Experiments](/evaluation/concepts): Opik allows you to automated the evaluation process of your LLM application so that you no longer need to manually review every LLM response. 3. [Opik's evaluation metrics](/evaluation/metrics/overview): Opik provides a suite of evaluation metrics (Hallucination, Answer Relevance, Context Recall, etc.) that you can use to score your LLM responses. 4. [Opik's MCP server](/mcp-server): Connect your AI coding assistant to Opik so it can read traces, log scores and run evaluations without you leaving your editor. > Debug, evaluate, and monitor your LLM applications, RAG systems, and agentic workflows with comprehensive tracing, automated evaluations, and production-ready dashboards.