LiteLLM - FriendliAI Docs (original) (raw)
You can use LiteLLM to interact with FriendliAI. This makes migration of existing applications already using LiteLLM particularly easy.
How to use
Before you start, ensure you’ve already obtained the API_KEY from the Friendli Suite > Personal Settings > API Keys. Add friendliai prefix to your endpoint name for the model parameter.
Chat completion
We provide usage examples for each type of endpoint. Choose the one that best suits your needs. You can specify one of the available models for the Model APIs.
import os
from litellm import completion
os.environ['API_KEY'] = "YOUR_API_KEY"
response = completion(
model="friendliai/zai-org/GLM-5.2",
messages=[
{"role": "user", "content": "hello from litellm"}
],
)
print(response)
Chat completion - Streaming
import os
from litellm import completion
os.environ['API_KEY'] = "YOUR_API_KEY"
response = completion(
model="friendliai/zai-org/GLM-5.2",
messages=[
{"role": "user", "content": "hello from litellm"}
],
stream=True
)
for chunk in response:
print(chunk)