Skip to main content
Create an API Key and send your first request. Once you complete these steps, you’re ready to build fast with FriendliAI. With Friendli Model APIs, you get access to a curated set of popular, open-weight models that are ready for you today. If you want to run any model — including your own — on dedicated GPUs, try Friendli Dedicated Endpoints. To get started, complete the following steps.

Create an API Key

Send a Request

Once you create your FriendliAI API Key, you’re ready to send your first request:
1

Set Up Your API Key

In your terminal, run the following command:
export FRIENDLIAI_API_KEY="<FRIENDLIAI_API_KEY>"
Replace <FRIENDLIAI_API_KEY> with your API Key.
2

Install the OpenAI SDK

In your terminal, run the following command:
pip install openai
3

Send Your Request to FriendliAI

Run the following code:
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.friendli.ai/serverless/v1",
    api_key=os.environ["FRIENDLIAI_API_KEY"],
)

completion = client.chat.completions.create(
    model="zai-org/GLM-5.2",
    messages=[
        {"role": "system", "content": "You are a friendly assistant."},
        {"role": "user", "content": "Describe FriendliAI in one sentence."},
    ],
)

print(completion.choices[0].message)
If you’d like to use a different model, replace zai-org/GLM-5.2 with another model. To browse all models, see Models > Model APIs.
FriendliAI returns a response, similar to the following:
{
  "id": "chatcmpl-04eb40ba7fc14cf8a51b7869d9cfa76f",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "FriendliAI is a generative AI infrastructure company that provides optimized solutions to help businesses deploy large language models faster, more efficiently, and at a lower cost.",
        "reasoning": "...",
        "reasoning_content": "..."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "created": 1781892285,
  "usage": {
    "completion_tokens": 412,
    "prompt_tokens": 27,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "total_tokens": 439
  },
  "model": "zai-org/GLM-5.2"
}
Congratulations. You sent your first request and are ready to build your next AI project.

Use Your Agent or SDK

You’re ready to start building with your favorite coding agent or SDK to connect to fast, cost-efficient, and reliable open-weight models. Choose how you work:

Agents

Use your favorite agent with FriendliAI.

SDKs

Use your favorite SDK with FriendliAI.
Last modified on June 24, 2026