# Together AI Trace Together AI model calls with cetra from Python, through the Together SDK or the OpenAI client. Trace Together AI model calls with cetra from Python, through the Together SDK or the OpenAI client. ## Install **Python** ```bash pip install "cetra-sdk[together]" together ``` ## Set up **Python** ```python import os import cetra from together import Together cetra.init(instrument=["together"]) client = Together(api_key=os.environ["TOGETHER_API_KEY"]) response = client.chat.completions.create( model="meta-llama/Llama-3.3-70B-Instruct-Turbo", messages=[{"role": "user", "content": "What is the capital of France?"}], ) print(response.choices[0].message.content) cetra.flush() ``` ## Through the OpenAI client Together AI also serves an OpenAI-compatible endpoint. The provider comes from the endpoint host. ```python import os import cetra from openai import OpenAI cetra.init(instrument=["openai"]) client = OpenAI(base_url="https://api.together.ai/v1", api_key=os.environ["TOGETHER_API_KEY"]) response = client.chat.completions.create( model="meta-llama/Llama-3.3-70B-Instruct-Turbo", messages=[{"role": "user", "content": "What is the capital of France?"}], ) print(response.choices[0].message.content) cetra.flush() ``` ## What you get - Each chat completion is an `llm` span with the provider `together_ai`. - Input and output token counts come from the response. - Cost comes from the built-in prices. - Through the OpenAI client, the endpoint host is in `server.address`, and cetra names the provider from it. ## Limits - The fixtures were captured with together 3.1.1 and openinference-instrumentation-together 0.1.20. - If a field is missing, look at the span's **Attributes** tab and compare it with [Span attributes](https://cetra.sh/docs/reference/attributes/). ## Next - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline. - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts. - [Custom model prices](https://cetra.sh/docs/tracing/cost-and-tokens/#custom-model-prices): price a model the built-in prices do not cover.