> ## Documentation Index
> Fetch the complete documentation index at: https://arizeai-433a7140.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Novita AI Tracing

> Trace Novita AI calls in Phoenix with OpenInference auto-instrumentation for the OpenAI Python SDK, since Novita AI provides an OpenAI-compatible API endpoint.

[Novita AI](https://novita.ai/) provides model APIs with OpenAI-compatible chat completions support. Point the OpenAI client at Novita AI's OpenAI-compatible endpoint and use [`openinference-instrumentation-openai`](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-openai) to send traces to Phoenix.

> [!NOTE]
>
> This page uses Novita AI's OpenAI-compatible API. There is no separate Novita-specific OpenInference instrumentor required.

## Install

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
pip install arize-phoenix-otel openinference-instrumentation-openai openai
```

## Setup

Add your Novita AI API key and the model you want to call as environment variables:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export NOVITA_API_KEY="<your-novita-api-key>"
export NOVITA_MODEL="<your-novita-model-id>"
```

Connect your application to Phoenix with the `register` function:

from phoenix.otel import register

&#x20; \# configure the Phoenix tracer
&#x20; tracer\_provider = register(
&#x20; project\_name="my-llm-app", # Default is 'default'
&#x20; auto\_instrument=True # Auto-instrument your app based on installed OI dependencies
&#x20; )

## Run Novita AI

```python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.novita.ai/openai",
    api_key=os.environ["NOVITA_API_KEY"],
)

response = client.chat.completions.create(
    model=os.environ["NOVITA_MODEL"],
    messages=[
        {
            "role": "user",
            "content": "What should teams inspect when an LLM answer is wrong?",
        },
    ],
)

print(response.choices[0].message.content)
```

## Observe

Now that you have tracing set up, all invocations of the OpenAI client pointed at Novita AI will be streamed to your running Phoenix for observability and evaluation. Each call appears as a `ChatCompletion` LLM span with the prompt, response, model name, token usage, and latency.

## Common Issues

* **Spans missing**: `register(..., auto_instrument=True)` must run before your application sends requests, and `openinference-instrumentation-openai` must be installed in the same environment
* **`401` from Novita AI**: Use your Novita AI API key, not an OpenAI key
* **Model not found**: Confirm `NOVITA_MODEL` matches a model identifier available in your Novita AI account
* **Base URL**: Ensure you're using `https://api.novita.ai/openai` as the base URL

## Resources

> **[Novita AI LLM API](https://novita.ai/docs/guides/llm-api)**
>
> Novita AI LLM API docs

> **[OpenInference OpenAI Instrumentation](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-openai)**
>
> OpenAI instrumentation package
