Skip to main content

Introduction

The Friendli Python SDK provides a powerful and flexible way to interact with FriendliAI services, including Model APIs, Dedicated Endpoints, and Container. You can easily integrate your Python applications with FriendliAI.

Installation

You can install the SDK with either pip or poetry:

Authentication

Authenticate using a Personal API key, which you can generate from Friendli Suite > Personal Settings > API Keys:
For detailed instructions on generating an API key, see the Manage Your FriendliAI API Keys guide.

Chat Completions

The SDK supports chat completions across all deployment types. Choose the deployment option that best fits your needs.

Asynchronous Chat Completions

Advanced Features

Streaming Responses

The SDK supports streaming responses using server-sent events, which you can consume using a simple for loop:

Custom Retry Strategy

You can customize retry behavior for operations that support retries:

Error Handling

The SDK provides comprehensive error handling with detailed exception information:

Custom Logging

You can pass your own logger to the client class to help troubleshoot and diagnose issues during API interactions. This is especially useful when you encounter unexpected behavior or errors.

Further Resources

For complete API documentation, advanced usage examples, and detailed reference information, visit the Friendli Python SDK GitHub repository.
Last modified on September 9, 2026