curl https://api.pipellm.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PIPELLM_API_KEY" \
-d '{
"model": "gpt-5",
"messages": [{"role": "user", "content": "Hello"}]
}'
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai/v1",
)
print(client.chat.completions.create(
model="gpt-5",
messages=[{"role": "user", "content": "Hello"}],
).choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.PIPELLM_API_KEY,
baseURL: "https://api.pipellm.ai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);
{
"id": "<string>",
"object": "<string>",
"model": "<string>",
"choices": [
{
"index": 123,
"message": {},
"delta": {},
"finish_reason": "<string>"
}
],
"usage": {}
}Create a chat completion
Create a model response for a chat conversation. Supports streaming.
POST
/
v1
/
chat
/
completions
curl https://api.pipellm.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PIPELLM_API_KEY" \
-d '{
"model": "gpt-5",
"messages": [{"role": "user", "content": "Hello"}]
}'
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai/v1",
)
print(client.chat.completions.create(
model="gpt-5",
messages=[{"role": "user", "content": "Hello"}],
).choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.PIPELLM_API_KEY,
baseURL: "https://api.pipellm.ai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);
{
"id": "<string>",
"object": "<string>",
"model": "<string>",
"choices": [
{
"index": 123,
"message": {},
"delta": {},
"finish_reason": "<string>"
}
],
"usage": {}
}Use
Authorization: Bearer $PIPELLM_API_KEY. Pick model from GET /v1/models.
Endpoint
POST https://api.pipellm.ai/v1/chat/completions
This free route accepts OpenAI-compatible requests and routes only to
OpenAI-compatible platforms. To keep the OpenAI format while calling
Anthropic or Gemini models, use the
OpenAI Format Converter.
curl https://api.pipellm.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PIPELLM_API_KEY" \
-d '{
"model": "gpt-5",
"messages": [{"role": "user", "content": "Hello"}]
}'
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PIPELLM_API_KEY"],
base_url="https://api.pipellm.ai/v1",
)
print(client.chat.completions.create(
model="gpt-5",
messages=[{"role": "user", "content": "Hello"}],
).choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.PIPELLM_API_KEY,
baseURL: "https://api.pipellm.ai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);
Code Examples
- cURL
- Python
- Node.js
- Go
curl https://api.pipellm.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PIPELLM_API_KEY" \
-d '{
"model": "gpt-5",
"max_completion_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Why is the sky blue?"
}
]
}'
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv('PIPELLM_API_KEY'),
base_url='https://api.pipellm.ai/v1'
)
response = client.chat.completions.create(
model='gpt-5',
messages=[
{
'role': 'user',
'content': 'Why is the sky blue?'
}
]
)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.PIPELLM_API_KEY,
baseURL: 'https://api.pipellm.ai/v1'
});
const response = await client.chat.completions.create({
model: 'gpt-5',
messages: [
{
role: 'user',
content: 'Why is the sky blue?'
}
]
});
package main
import (
"context"
"os"
openai "github.com/sashabaranov/go-openai"
)
func main() {
config := openai.DefaultConfig(os.Getenv("PIPELLM_API_KEY"))
config.BaseURL = "https://api.pipellm.ai/v1"
client := openai.NewClientWithConfig(config)
resp, _ := client.CreateChatCompletion(
context.Background(),
openai.ChatCompletionRequest{
Model: "gpt-5",
Messages: []openai.ChatCompletionMessage{
{
Role: openai.ChatMessageRoleUser,
Content: "Why is the sky blue?",
},
},
},
)
}
Request Parameters
Pickmodel from GET /v1/models. Native /v1/chat/completions only routes to OpenAI-compatible platforms.
string
required
Model ID visible to your account.
array
required
Conversation messages. At least one item.
Show messages[]
Show messages[]
string
required
system, user, assistant, or tool.string | array
required
string
Optional speaker name.
string
Required when
role is tool.number
Sampling temperature, 0–2. Default
1.integer
Maximum tokens to generate.
integer
Preferred maximum for newer OpenAI-compatible models. Use this instead of
max_tokens when the model requires it.object
Streaming extras.
Show stream_options fields
Show stream_options fields
boolean
If
true, the last SSE chunk includes usage.number
Nucleus sampling, 0–1.
integer
Number of completions to generate. Default
1.string | string[]
Stop sequence or list of stop sequences.
number
Presence penalty, -2 to 2. Default
0.number
Frequency penalty, -2 to 2. Default
0.array
string | object
auto, none, or {"type":"function","function":{"name":"..."}}.string
End-user identifier for abuse tracking.
Response Format
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1234567890,
"model": "gpt-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The sky appears blue because..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 50,
"total_tokens": 60
}
}
string
Completion ID.
string
chat.completion, or chat.completion.chunk when streaming.string
Model that produced the response.
array
object
Token counts:
prompt_tokens, completion_tokens, total_tokens.Errors
Same envelope as Errors.400 invalid_request_error
400 invalid_request_error
Malformed JSON, missing
model / messages, or a protocol mismatch on this native route.{
"error": {
"type": "invalid_request_error",
"code": "400",
"message": "The 'model' field is required but was not provided in the request"
}
}
401 authentication_error
401 authentication_error
Missing or invalid API key.
{
"error": {
"type": "authentication_error",
"code": "401",
"message": "Incorrect API key provided. Please visit https://console.pipellm.ai/account/api-keys to find your API key."
}
}
402 insufficient_balance
402 insufficient_balance
Balance check failed before the request was processed.
{
"error": {
"type": "insufficient_balance",
"code": "402",
"message": "Insufficient balance. Please recharge your account at https://console.pipellm.ai/billing."
}
}
429 rate_limit_error
429 rate_limit_error
Account RPM exceeded. See Rate Limits.
{
"error": {
"type": "rate_limit_error",
"code": "429",
"message": "Rate limit exceeded. Your current limit is 120 requests per minute (approximately 2.00 requests per second). Please visit https://console.pipellm.ai/billing to upgrade your plan for higher limits."
}
}
Function Calling
Function Calling allows models to generate structured JSON to call functions in your code.- Python
- Node.js
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}
]
response = client.chat.completions.create(
model="gpt-5",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=tools,
tool_choice="auto"
)
if response.choices[0].message.tool_calls:
tool_call = response.choices[0].message.tool_calls[0]
# Execute your function and return result
const tools = [
{
type: "function",
function: {
name: "get_weather",
description: "Get the current weather in a location",
parameters: {
type: "object",
properties: {
location: { type: "string", description: "City name" }
},
required: ["location"]
}
}
}
];
const response = await client.chat.completions.create({
model: 'gpt-5',
messages: [{ role: 'user', content: "What's the weather in Tokyo?" }],
tools: tools,
tool_choice: 'auto'
});
if (response.choices[0].message.tool_calls) {
const toolCall = response.choices[0].message.tool_calls[0];
// Execute your function and return result
}
Function Calling Documentation
Complete guide on defining functions and handling responses
Was this page helpful?