Obiguard provides a robust and secure gateway to facilitate the integration of various Large Language Models (LLMs) into your applications, including Lepton AI APIs.
With Obiguard, you can take advantage of features like fast AI gateway access, observability, prompt management, and more, all while ensuring the secure management of your LLM API keys through a virtual key system.
from obiguard import Obiguardclient = Obiguard( obiguard_api_key="sk-obg***", # Your Obiguard API key virtual_key="VIRTUAL_KEY" # Replace with your virtual key for Lepton)
Copy
from obiguard import Obiguardclient = Obiguard( obiguard_api_key="sk-obg***", # Your Obiguard API key virtual_key="VIRTUAL_KEY" # Replace with your virtual key for Lepton)
Use the Obiguard instance to send requests to Lepton AI. You can also override the virtual key directly in the API call if needed.
Copy
completion = client.chat.completions.create( messages= [{"role": 'user', "content": 'Say this is a test'}], model= 'llama-3-8b-sft-v1')print(completion)
Copy
completion = client.chat.completions.create( messages= [{"role": 'user', "content": 'Say this is a test'}], model= 'llama-3-8b-sft-v1')print(completion)
Lepton AI supports streaming responses to provide real-time generation:
Copy
stream = client.chat.completions.create( messages=[{"role": "user", "content": "Write a story about a robot"}], model="llama-3-8b-sft-v1", stream=True)for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")
Copy
stream = client.chat.completions.create( messages=[{"role": "user", "content": "Write a story about a robot"}], model="llama-3-8b-sft-v1", stream=True)for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")