OpenAI Python SDK
Integrate FriendliAI with OpenAI Python SDK for chat, streaming, and more.
You can use OpenAI Python SDK to interact with FriendliAI. This makes migration of existing applications already using OpenAI particularly easy.
How to use
Before you start, ensure the base_url
and api_key
refer to FriendliAI.
Since our products are entirely compatible with OpenAI SDK, now you are good to follow the examples below.
Choose one of the available models for model
parameter.
Chat Completion
Chat completion API that generates a response from a given conversation.
We provide multiple usage examples. Try to find the best one that aligns with your needs.
Tool assisted chat completion
This feature is in Beta and available only on the Serverless Endpoints.
Using tool assisted chat completion API, models can utilize built-in tools prepared for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
Available tools are listed here.