OpenObserve Docs

DeepSeek → OpenObserve

Updated View MarkdownOpen in ChatGPTOpen in Claude

Automatically capture token usage, latency, and model metadata for every DeepSeek inference call in your Python application. DeepSeek exposes an OpenAI-compatible API, so instrumentation uses the standard OpenAI instrumentor pointed at the DeepSeek endpoint.

Prerequisites

  • Python 3.9+
  • An OpenObserve account (cloud or self-hosted)
  • Your OpenObserve organisation ID and Base64-encoded auth token
  • A DeepSeek API key

Installation

pip install openobserve-python-sdk openinference-instrumentation-openai openai python-dotenv

Configuration

Create a .env file in your project root:

OPENOBSERVE_URL=https://api.openobserve.ai/
OPENOBSERVE_ORG=your_org_id
OPENOBSERVE_AUTH_TOKEN=Basic <your_base64_token>
DEEPSEEK_API_KEY=your-deepseek-api-key

Instrumentation

Call OpenAIInstrumentor().instrument() before creating the OpenAI client. Point the client at the DeepSeek base URL and pass your DeepSeek API key.

from dotenv import load_dotenv
load_dotenv()

from openinference.instrumentation.openai import OpenAIInstrumentor
from openobserve import openobserve_init

OpenAIInstrumentor().instrument()
openobserve_init()

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["DEEPSEEK_API_KEY"],
    base_url="https://api.deepseek.com/v1",
)

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "Explain distributed tracing in one sentence."}],
)
print(response.choices[0].message.content)

What Gets Captured

AttributeDescription
llm_providerdeepseek
llm_systemopenai (OpenAI-compatible client)
llm_model_nameResolved model returned by the API (e.g. deepseek-v4-flash)
gen_ai_request_max_tokensmax_tokens value from the request
gen_ai_response_modelSame as llm_model_name
gen_ai_operation_namechat
llm_token_count_promptPrompt tokens consumed
llm_token_count_completionCompletion tokens returned
llm_token_count_totalTotal tokens consumed
llm_token_count_prompt_details_cache_readPrompt cache read tokens
gen_ai_usage_input_tokensInput tokens (mirrors llm_token_count_prompt)
gen_ai_usage_output_tokensOutput tokens (mirrors llm_token_count_completion)
gen_ai_usage_total_tokensTotal tokens (mirrors llm_token_count_total)
openinference_span_kindLLM
operation_nameChatCompletion
input_mime_typeapplication/json
output_mime_typeapplication/json
durationEnd-to-end request latency
span_statusOK on success, ERROR on failure

Viewing Traces

  1. Log in to OpenObserve and navigate to Traces
  2. Spans appear with operation_name: ChatCompletion and llm_provider: deepseek
  3. Note that deepseek-chat resolves to the actual model in llm_model_name (e.g. deepseek-v4-flash)
  4. Filter by llm_provider to isolate DeepSeek spans from other providers

DeepSeek trace in OpenObserve, Waterfall view with the ChatCompletion span attributes

Next Steps

With DeepSeek instrumented, every inference call is recorded in OpenObserve. From here you can monitor token usage, compare latency across model aliases, and set alerts on error spans.

Read More

Was this page helpful?

On this page