Examples
# Basic request
curl -X POST httpbun.com/llm/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "Hello!"}]}'
# With custom response
curl -X POST httpbun.com/llm/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [...], "httpbun": {"content": "Custom reply!"}}'
# Streaming
curl -N httpbun.com/llm/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [...], "stream": true}'
# Python with OpenAI SDK
from openai import OpenAI
client = OpenAI(
base_url="httpbun.com/llm",
api_key="not-needed",
)
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}],
extra_body={"httpbun": {"content": "Hi! How can I help?"}},
)
print(response.choices[0].message.content)
# Output: Hi! How can I help?