Automata 1RPC
  • LLM relay
    • Overview
  • Using the LLM API
    • Getting started
    • Models
    • Payment
    • Authentication
    • Errors
  • Web3 Relay
    • Overview
  • USING THE WEB3 API
    • Getting started
    • Transaction sanitizers
    • Networks
    • Payment
      • How to make a payment
        • Fiat Payment
        • Crypto Payment
      • How to top up crypto payment
      • How to change billing cycle
      • How to change from fiat to crypto payment
      • How to change from crypto to fiat payment
      • How to upgrade or downgrade plan
      • How to cancel a plan
      • How to update credit card
      • How to view payment history
      • Policy
    • Errors
  • Getting help
    • Discord
    • Useful links
Powered by GitBook
On this page
  • Direct API requests
  • OpenAI TypeScript SDK
  1. Using the LLM API

Authentication

The LLM relay uses Bearer tokens for authentication. Your API key acts as the Bearer token, which 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> if you're 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 the api_base to https://1rpc.ai/v1 and pass your API key as theapiKey .

import OpenAI from 'openai';
const openai = new OpenAI({
  baseURL: 'https://1rpc.ai/v1',
  apiKey: '<1RPC_AI_API_KEY>',
});

PreviousPaymentNextErrors

Last updated 1 month ago

Page cover image