You will need Portkey and Together AI API keys to get started
With OpenAI Client
OpenAI Python
With Portkey Client
Add your Together API key in Model Catalog and access models using your provider slugPython
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
🎉 Portkey raises Series A - $15M to build AI that never breaks  Read announcement →
Try out the new Llama 3 model directly using the OpenAI SDK
| Grab Portkey API Key | Grab Together AI API Key |
|---|
pip install -qU portkey-ai openai
from openai import OpenAI
from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders
openai = OpenAI(
api_key='TOGETHER_API_KEY', # Grab from https://api.together.xyz/
base_url=PORTKEY_GATEWAY_URL,
default_headers=createHeaders(
provider="together-ai",
api_key='PORTKEY_API_KEY' # Grab from https://app.portkey.ai/
)
)
response = openai.chat.completions.create(
model="meta-llama/Llama-3-8b-chat-hf",
messages=[{"role": "user", "content": "What's a fractal?"}],
max_tokens=500
)
print(response.choices[0].message.content)
from portkey_ai import Portkey
portkey = Portkey(api_key="PORTKEY_API_KEY")
response = portkey.chat.completions.create(
model="@together-prod/meta-llama/Llama-3-8b-chat-hf", # @provider-slug/model
messages=[{"role": "user", "content": "Who are you?"}],
max_tokens=500
)
print(response.choices[0].message.content)
Was this page helpful?
