Skip to main content
GitHub

Providers

Auto-instrumentation for LLM providers.

Risicare automatically instruments popular LLM providers with zero code changes.

Supported Providers

Python SDK

Python providers are auto-instrumented — risicare.init() patches them on import; there are no explicit patchX() calls (that is the JS SDK's model).

JavaScript SDK

The JS SDK supports the same 12 native providers via explicit patchX() calls, plus 8 host-detected providers via patchOpenAI():

Additional JS providers (Google, Mistral, Groq, Cohere, Together, Ollama, HuggingFace, Cerebras, Bedrock) follow the same pattern — import from risicare/<provider> and call patchX(client). See the JS SDK reference for the full list.

How It Works

When you call risicare.init(), the SDK automatically patches supported provider libraries:

import risicare
from openai import OpenAI
 
risicare.init()
 
client = OpenAI()
 
# This call is automatically traced
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)

Captured Data

For each LLM call, the SDK captures:

FieldDescription
modelModel name (gpt-4o, claude-3-sonnet, etc.)
providerProvider name (openai, anthropic, etc.)
prompt_tokensInput token count
completion_tokensOutput token count
total_tokensTotal token count
latency_msRequest duration
temperatureSampling temperature
max_tokensMaximum output tokens
promptInput prompt (if trace_content=True)
completionOutput completion (if trace_content=True)

The SDK does not compute cost. Risicare calculates cost from captured token counts using current model pricing.

Manual Instrumentation

If auto-instrumentation doesn't meet your needs:

from risicare import trace, SpanKind
 
@trace(name="custom-llm-call", kind=SpanKind.LLM_CALL)
def call_custom_llm(prompt: str) -> str:
    # Your custom LLM call
    return response

You can also set provider and model attributes manually:

from risicare import get_tracer, SpanKind
 
tracer = get_tracer()
 
with tracer.start_span("custom-llm", kind=SpanKind.LLM_CALL) as span:
    span.set_attribute("llm.provider", "custom")
    span.set_attribute("llm.model", "my-model")
    response = call_llm(prompt)

Next Steps

Select a provider to see detailed integration guides: