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.
from traceai_openai import OpenAIInstrumentorOpenAIInstrumentor().instrument(tracer_provider=trace_provider)
5. Interact with Together AI
Interact with the Together AI through OpenAI Client. Our OpenAI Instrumentor will automatically trace and send the telemetry data to our platform.
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)
{"docsConfig":{"theme":"willow","$schema":"https://mintlify.com/docs.json","name":"Future AGI Documentation","colors":{"primary":"#7857FC","light":"#CF6BE8","dark":"#7A40D9"},"logo":{"light":"https://mintcdn.com/futureagi/2N-fL6y8Hy-fXoFn/logo/logo_light.svg?fit=max\u0026auto=format\u0026n=2N-fL6y8Hy-fXoFn\u0026q=85\u0026s=c9313c64fc84ebf190a6a1587a0d3090","dark":"https://mintcdn.com/futureagi/2N-fL6y8Hy-fXoFn/logo/logo_dark.svg?fit=max\u0026auto=format\u0026n=2N-fL6y8Hy-fXoFn\u0026q=85\u0026s=85f9b2c1501c57e51d86092311acc5b9"},"favicon":"/logo/Icon.svg","api":{"playground":{"display":"interactive","proxy":true},"examples":{"defaults":"required","languages":["curl","python","javascript"],"prefill":false}},"appearance":{"default":"dark","strict":false},"background":{"decoration":"gradient","color":{"light":"#FFFFFF","dark":"#090612"}},"navbar":{"links":[{"icon":"github","href":"https://github.com/future-agi","label":"GitHub"},{"icon":"discord","href":"https://discord.gg/n2tCUKBkAw","label":"Community"}],"primary":{"type":"button","label":"Dashboard","href":"https://app.futureagi.com"}},"seo":{"metatags":{"description":"Future AGI provides a comprehensive platform for building, evaluating, and optimizing AI applications. Explore guides on LLM evaluation, agent simulation, dataset management, prompt engineering, prototyping, observability, and AI safety. Integrate with popular frameworks like LangChain and LlamaIndex, and leverage our Python SDK and API for advanced AI development.","keywords":"Future AGI, AI, LLM, AGI, Evaluation, Observability, Prompt Engineering, RAG, AI Agents, Machine Learning, API, SDK, Documentation, Guides, Cookbooks, Integrations, Simulation, Dataset Management, Prototype, Agent Compass, Optimization, AI Safety, Knowledge Base, LangChain, LlamaIndex, OpenAI, Anthropic, MistralAI, AutoGen, Guardrails, VertexAI, Google GenAI, CrewAI, DSPy, Groq, Haystack, Portkey","author":"Future AGI Team","title":"Future AGI Docs","og:url":"https://docs.futureagi.com","og:image":"images/agi2.png"}},"integrations":{"ga4":{"measurementId":"G-454965535"},"mixpanel":{"projectToken":"943ee62711f4c19b254ea1591950c5c1"}},"errors":{"404":{"redirect":true}},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"futureagi","hasAudioNarration":false,"actualSubdomain":"futureagi","customDomains":[],"gitSource":{"type":"github","owner":"future-agi","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":"","_id":"6b10ab159ffae5051c3fc630"},"feedback":{"edits":true,"thumbs":true},"entitlements":{},"buildId":"6ae922e27d386b1c81ef7e94:success","clientVersion":"0.0.4436","searchFilterCounts":[{"language":"default","tag":"Documentation","count":182},{"language":"default","tag":"Guides","count":177},{"language":"default","tag":"Evaluation","count":75},{"language":"default","tag":"Cookbooks","count":72},{"language":"default","tag":"Integrations","count":65},{"language":"default","tag":"Built-in Evals","count":65},{"language":"default","tag":"API Reference","count":38},{"language":"default","tag":"How To","count":36},{"language":"default","tag":"Observability","count":32},{"language":"default","tag":"Tracing","count":22}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":true},"customCss":[]}
{"page":{"pagePath":"integrations/togetherai","slug":"/integrations/togetherai","pageMetadata":{"title":"Together AI","description":null,"href":"/integrations/togetherai"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,hr:`hr`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,Heading}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`1-installation`,children:`1. Installation`}),`\n`,_jsx(_components.p,{children:`First install the traceAI package to access the observability framework`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`pip`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` traceAI-openai`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`2-set-environment-variables`,children:`2. Set Environment Variables`}),`\n`,_jsx(_components.p,{children:`Set up your environment variables to authenticate with both FutureAGI and OpenAI services.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"TOGETHER_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"your-together-api-key\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"FI_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"your-futureagi-api-key\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"FI_SECRET_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"your-futureagi-secret-key\"`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`3-initialize-trace-provider`,children:`3. Initialize Trace Provider`}),`\n`,_jsx(_components.p,{children:`Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines .`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fi_instrumentation `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` register`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fi_instrumentation.fi_types `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ProjectType`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`trace_provider `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` register(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` project_type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`ProjectType.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`OBSERVE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` project_name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"togetherai_project\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`4-instrument-your-project`,children:`4. Instrument your Project`}),`\n`,_jsx(_components.p,{children:`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.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` traceai_openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAIInstrumentor`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`OpenAIInstrumentor().instrument(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`tracer_provider`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`trace_provider)`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`5-interact-with-together-ai`,children:`5. Interact with Together AI`}),`\n`,_jsx(_components.p,{children:`Interact with the Together AI through OpenAI Client. Our OpenAI Instrumentor will automatically trace and send the telemetry data to our platform.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`16`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai.OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"TOGETHER_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.together.xyz/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"system\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a travel agent. Be descriptive and helpful.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Tell me the top 3 things to do in San Francisco\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(response.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content)`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Together AI","description":null,"href":"/integrations/togetherai"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"1. Installation","slug":"1-installation","depth":2,"children":[]},{"title":"2. Set Environment Variables","slug":"2-set-environment-variables","depth":2,"children":[]},{"title":"3. Initialize Trace Provider","slug":"3-initialize-trace-provider","depth":2,"children":[]},{"title":"4. Instrument your Project","slug":"4-instrument-your-project","depth":2,"children":[]},{"title":"5. Interact with Together AI","slug":"5-interact-with-together-ai","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"futureagi","siteName":"Future AGI Documentation","title":"Together AI - Future AGI Documentation","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-03-19T11:41:16.594Z","originalFileLocation":"integrations/togetherai.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Future AGI provides a comprehensive platform for building, evaluating, and optimizing AI applications. Explore guides on LLM evaluation, agent simulation, dataset management, prompt engineering, prototyping, observability, and AI safety. Integrate with popular frameworks like LangChain and LlamaIndex, and leverage our Python SDK and API for advanced AI development.\">\u003cmeta data-mint-head name=\"keywords\" content=\"Future AGI, AI, LLM, AGI, Evaluation, Observability, Prompt Engineering, RAG, AI Agents, Machine Learning, API, SDK, Documentation, Guides, Cookbooks, Integrations, Simulation, Dataset Management, Prototype, Agent Compass, Optimization, AI Safety, Knowledge Base, LangChain, LlamaIndex, OpenAI, Anthropic, MistralAI, AutoGen, Guardrails, VertexAI, Google GenAI, CrewAI, DSPy, Groq, Haystack, Portkey\">\u003cmeta data-mint-head name=\"application-name\" content=\"Future AGI Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Together AI - Future AGI Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Future AGI provides a comprehensive platform for building, evaluating, and optimizing AI applications. Explore guides on LLM evaluation, agent simulation, dataset management, prompt engineering, prototyping, observability, and AI safety. Integrate with popular frameworks like LangChain and LlamaIndex, and leverage our Python SDK and API for advanced AI development.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Future AGI Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://futureagi.mintlify.app/integrations/togetherai\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://futureagi.mintlify.site/images/agi2.png\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Together AI - Future AGI Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Future AGI provides a comprehensive platform for building, evaluating, and optimizing AI applications. Explore guides on LLM evaluation, agent simulation, dataset management, prompt engineering, prototyping, observability, and AI safety. Integrate with popular frameworks like LangChain and LlamaIndex, and leverage our Python SDK and API for advanced AI development.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://futureagi.mintlify.site/images/agi2.png\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/futureagi/kcO1St7gSVhRaZUu/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Future AGI Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#7857FC\">\u003cmeta data-mint-head name=\"author\" content=\"Future AGI Team\">\u003clink data-mint-head rel=\"canonical\" href=\"https://futureagi.mintlify.app/integrations/togetherai\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/integrations/togetherai.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://futureagi.mintlify.app/#organization\",\"name\":\"Future AGI Documentation\",\"url\":\"https://futureagi.mintlify.app\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/futureagi/2N-fL6y8Hy-fXoFn/logo/logo_light.svg?fit=max\u0026auto=format\u0026n=2N-fL6y8Hy-fXoFn\u0026q=85\u0026s=c9313c64fc84ebf190a6a1587a0d3090\"}},{\"@type\":\"WebSite\",\"@id\":\"https://futureagi.mintlify.app#website\",\"name\":\"Future AGI Documentation\",\"url\":\"https://futureagi.mintlify.app\",\"publisher\":{\"@id\":\"https://futureagi.mintlify.app/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://futureagi.mintlify.app/integrations/togetherai#webpage\",\"url\":\"https://futureagi.mintlify.app/integrations/togetherai\",\"name\":\"Together AI\",\"dateModified\":\"2026-03-19T11:41:16.594Z\",\"isPartOf\":{\"@id\":\"https://futureagi.mintlify.app#website\"},\"breadcrumb\":{\"@id\":\"https://futureagi.mintlify.app/integrations/togetherai#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://futureagi.mintlify.app/integrations/togetherai#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Integrations\",\"item\":\"https://futureagi.mintlify.app/integrations/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Together AI\",\"item\":\"https://futureagi.mintlify.app/integrations/togetherai\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://futureagi.mintlify.app/integrations/togetherai#article\",\"headline\":\"Together AI\",\"name\":\"Together AI\",\"url\":\"https://futureagi.mintlify.app/integrations/togetherai\",\"mainEntityOfPage\":{\"@id\":\"https://futureagi.mintlify.app/integrations/togetherai#webpage\"},\"image\":\"https://futureagi.mintlify.app/images/agi2.png\",\"dateModified\":\"2026-03-19T11:41:16.594Z\",\"publisher\":{\"@id\":\"https://futureagi.mintlify.app/#organization\"},\"isPartOf\":{\"@id\":\"https://futureagi.mintlify.app#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Future AGI Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Future AGI Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/integrations/togetherai.md","siteName":"Future AGI Documentation","nav":{"global":null,"tabs":[{"tab":"Documentation","icon":"book-open","pages":[{"title":"Documentation","href":"/home"}]},{"tab":"Integrations","icon":"plug","groups":[{"group":"Integrations","pages":[{"title":"Overview","href":"/integrations/overview"},{"title":"Anthropic","href":"/integrations/anthropic"},{"title":"Autogen","href":"/integrations/autogen"},{"title":"Bedrock","href":"/integrations/bedrock"},{"title":"Crew AI","href":"/integrations/crewai"},{"title":"DSPy","href":"/integrations/dspy"},{"title":"Google ADK","href":"/integrations/google_adk"},{"title":"Google GenAI","href":"/integrations/google_genai"},{"title":"Groq","href":"/integrations/groq"},{"title":"Guardrails","href":"/integrations/guardrails"},{"title":"Haystack","href":"/integrations/haystack"},{"title":"Instructor","href":"/integrations/instructor"},{"title":"LangChain","href":"/integrations/langchain"},{"title":"LangGraph","href":"/integrations/langgraph"},{"title":"LiteLLM","href":"/integrations/litellm"},{"title":"LiveKit","href":"/integrations/livekit"},{"title":"Llama Index","href":"/integrations/llamaindex"},{"title":"Llama Index Workflows","href":"/integrations/llamaindex-workflows"},{"title":"Mistral AI","href":"/integrations/mistralai"},{"title":"Mongodb","href":"/integrations/mongodb"},{"title":"n8n","href":"/integrations/n8n"},{"title":"Ollama","href":"/integrations/ollama"},{"title":"OpenAI","href":"/integrations/openai"},{"title":"OpenAI Agents","href":"/integrations/openai_agents"},{"title":"Pipecat","href":"/integrations/pipecat"},{"title":"Portkey","href":"/integrations/portkey"},{"title":"Prompt Flow","href":"/integrations/promptflow"},{"title":"Smol Agents","description":null,"href":"/integrations/smol_agents"},{"title":"Together AI","href":"/integrations/togetherai"},{"title":"Vercel","description":null,"href":"/integrations/vercel"},{"title":"Vertex AI (Gemini)","href":"/integrations/vertexai"}]}]},{"tab":"Cookbooks","icon":"book","pages":[{"title":"Cookbooks","href":"/cookbook/overview"}]},{"tab":"SDK Reference","icon":"code","pages":[{"title":"SDK Reference","href":"/sdk-reference/python-sdk-client"}]},{"tab":"API Reference","icon":"webhook","pages":[{"title":"API Reference","href":"/api-reference/health/health-check"}]}]},"basePath":"","title":"Together AI - Future AGI Documentation","deploymentId":"dpl_AYyV3CY85Zsy44WzfDVuMiAS7PWU","buildId":"dpl_AYyV3CY85Zsy44WzfDVuMiAS7PWU","dynamics":[],"chunks":[]}