Try out the new Llama 3 model directly using the OpenAI SDK
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', ## Grab from https://app.portkey.ai/ provider="@together-virtual-key" ## Grab from https://api.together.xyz/ and add to Portkey Virtual Keys ) response = portkey.chat.completions.create( model= 'meta-llama/Llama-3-8b-chat-hf', messages= [{ "role": 'user', "content": 'Who are you?'}], max_tokens=500 ) print(response.choices[0].message.content)
Was this page helpful?