Use the OpenAI Instrumentor to instrument your project, as the OpenAI Client is utilized for interactions with Together AI. This step guarantees that all interactions are tracked and monitored. If you are using a different client to interact with Together AI, use that client’s Instrumentor instead.
Copy
from traceai_openai import OpenAIInstrumentorOpenAIInstrumentor().instrument(tracer_provider=trace_provider)
Interact with the Together AI through OpenAI Client. Our OpenAI Instrumentor will automatically trace and send the telemetry data to our platform.
Copy
import openaiclient = openai.OpenAI( api_key=os.environ.get("TOGETHER_API_KEY"), base_url="https://api.together.xyz/v1",)response = client.chat.completions.create( model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", messages=[ {"role": "system", "content": "You are a travel agent. Be descriptive and helpful."}, {"role": "user", "content": "Tell me the top 3 things to do in San Francisco"}, ])print(response.choices[0].message.content)