Using the LLM API
Getting started
Learn how to make your first request to the 1RPC.ai LLM relay.
1RPC.ai provides a single endpoint with access to 38+ verified LLM models. The API is made available via the 1RPC.ai dashboard. At the same time, monitor and control spending across different AI models with aggregated usage in one place.
Immediately rotate your API key if you suspect that it has been leaked, compromised, or misused.
Sample request
import requests
import json
response = requests.post(
url="https://1rpc.ai/v1/chat/completions",
headers={
"Authorization": "Bearer <1RPC_AI_API_KEY>",
"Content-Type": "application/json",
"Accept": "application/json",
},
data=json.dumps({
"model":"openai/gpt-4o",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}]
)fetch('https://1rpc.ai/v1/chat/completions', {
method: 'Post',
headers: {
Authorization: 'Bearer <1RPC_AI_API_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'openai/gpt-4o',
messages: [
{
role: 'user',
content: 'What is the meaning of life?'
},
],
}),
});curl https://1rpc.ai/v1/chat/completions \
-H "Content-Type" application/json" \
-H "Authorization: Bearer $ONERPC_AI_API_KEY" \
-d '{
"model": openai/gpt-4o",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'