Using the LLM API
Authentication
Learn how to authorize requests to the LLM relay with Bearer tokens.

The LLM relay uses Bearer tokens for authentication. Your API key acts as the Bearer token and must be included in the Authorization header when making requests.
A Bearer token is a secure, stateless method of verifying API requests.
Direct API requests
Set the Authorization header to Bearer <1RPC_AI_API_KEY> when making direct API calls.
import openai
openai.api_base = "https://1rpc.ai/v1"
openai.api_key = "<1RPC_AI_API_KEY>"fetch('https://1rpc.ai/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: 'Bearer <1RPC_AI_API_KEY>',
'Content-Type': 'application/json',
},
});curl https://1rpc.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ONERPC_AI_API_KEY"OpenAI TypeScript SDK
Set baseURL to https://1rpc.ai/v1 and pass your API key as apiKey.
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'https://1rpc.ai/v1',
apiKey: '<1RPC_AI_API_KEY>',
});