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

The SDK can be installed with either pip or poetry:

Authentication

Authentication is done using a Personal API key, which can be generated from the Friendli Suite > Personal Settings > API Keys:
For detailed instructions on generating a Personal API key, see the Personal 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.

Beta Features

Dataset Management (Beta)

The SDK lets you create, retrieve, and update datasets in your projects. Datasets can contain samples across modalities—such as text, images, and more—for flexible fine-tuning and validation workflows.

File Management (Beta)

You can download and upload files to and from FriendliAI storage. This feature primarily stores sample files related to datasets, with additional use cases planned for the future.

Further Resources

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