PORDL API

Drop-in OpenAI replacement with smart model routing. Send requests to api.pordl.dev instead of api.openai.com, and PORDL routes each request to the cheapest model that can handle it.

Base URL for all API requests:

https://api.pordl.dev

All endpoints use JSON request/response bodies and follow OpenAI's API format — any OpenAI-compatible client works out of the box.

Quick Start

Node.js (SDK)

import Pordl from "@plagtech/pordl";

const client = new Pordl({ apiKey: "pd_live_..." });

const res = await client.chat.completions.create({
  model: "auto",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(res.choices[0].message.content);

Node.js (OpenAI SDK directly)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "pd_live_...",
  baseURL: "https://api.pordl.dev/v1",
});

Python

from openai import OpenAI

client = OpenAI(
    api_key="pd_live_...",
    base_url="https://api.pordl.dev/v1",
)

curl

curl https://api.pordl.dev/v1/chat/completions \
  -H "Authorization: Bearer pd_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Sign Up

POST /proxy/auth/signup

Create an account and receive your API key. Save the key — it won't be shown again.

Request

{
  "email": "you@example.com",     // required
  "password": "your-password"     // required
}

Response

{
  "message": "Account created",
  "user": {
    "id": "a15769e8-...",
    "email": "you@example.com",
    "tier": "free"
  },
  "api_key": "pd_live_6b7c140dd949cac44b14bb23b6cfa19a",
  "note": "Save this API key — it won't be shown again."
}

Log In

POST /proxy/auth/login

Log in and generate a new API key.

Request

{
  "email": "you@example.com",
  "password": "your-password"
}

API Keys

All authenticated requests require an API key in the Authorization header. Keys start with pd_live_ for production or pd_test_ for testing.

Authorization: Bearer pd_live_your_key_here

Keys are hashed and stored securely — PORDL never stores your raw key. If you lose your key, log in again to generate a new one.

Chat Completions

POST /v1/chat/completions

Send a chat completion request. Follows the OpenAI format exactly.

Request Body

ParameterTypeDescription
model required string Use "auto" for smart routing, or specify a model directly (e.g. "gpt-4o-mini")
messages required array Array of message objects with role and content
temperature optional number Sampling temperature, 0 to 2. Default: 1
max_tokens optional integer Maximum tokens in the response

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 8,
    "total_tokens": 20
  }
}

Models

GET /v1/models

List available models. No authentication required.

Smart Routing

When you set model: "auto", PORDL classifies your request by complexity and routes it to the cheapest model that can handle it:

ComplexityRouted ToExample
Simple gpt-4o-mini Factual Q&A, formatting, translation
Medium gpt-4o SQL queries, code review, analysis
Complex gpt-5.4 System design, multi-step reasoning

You can also pass a specific model name to bypass routing. The routing classification is returned in the x-pordl-complexity response header.

Response Headers

Every chat completion response includes routing metadata:

HeaderDescription
x-pordl-model Which model handled the request
x-pordl-complexity How the request was classified (simple / medium / complex)
x-pordl-routing Routing mode used (auto / direct)
x-pordl-cost Cost of the call in USD
x-pordl-savings Estimated savings vs. calling the most expensive model directly
x-pordl-latency Total response time in ms
x-pordl-cached true if response was served from cache
x-monthly-limit Your tier's monthly token limit
x-monthly-used Tokens used this billing period
x-monthly-remaining Tokens remaining this billing period

Pricing

Starter

$29 /mo
50,000 tokens

Pro

$79 /mo
250,000 tokens

Scale

$199 /mo
1,000,000 tokens

Checkout

POST /proxy/billing/checkout

Create a Stripe checkout session to subscribe to a paid tier. Returns a URL to redirect the user to.

Request

// Header: Authorization: Bearer pd_live_...
{
  "tier": "starter"   // "starter" | "pro" | "scale"
}

Response

{
  "url": "https://checkout.stripe.com/c/pay/cs_live_...",
  "tier": "starter"
}

Customer Portal

POST /proxy/billing/portal

Create a Stripe customer portal session to manage or cancel your subscription.

Usage

GET /proxy/auth/usage

Get your current usage stats for the billing period.

Request

Authorization: Bearer pd_live_...

Errors

Errors follow a consistent JSON format:

{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
HTTP CodeTypeMeaning
400invalid_request_errorBad request body or missing fields
401authentication_errorMissing or invalid API key
429rate_limit_errorRate limit or token quota exceeded
500server_errorSomething went wrong on our end

Rate Limits

Rate limits depend on your subscription tier:

TierMonthly TokensRequests / min
Free10,00010
Starter50,00060
Pro250,000120
Scale1,000,000300

Rate limit info is returned in response headers: x-ratelimit-limit-requests, x-ratelimit-remaining-requests, x-ratelimit-reset-requests.

SDK

Install the official Node.js SDK:

npm install @plagtech/pordl

The SDK is a thin wrapper around the OpenAI Node.js SDK — it sets baseURL to api.pordl.dev and handles auth. All OpenAI methods and types work as-is.

import Pordl from "@plagtech/pordl";

const client = new Pordl({ apiKey: "pd_live_..." });

const res = await client.chat.completions.create({
  model: "auto",
  messages: [{ role: "user", content: "What is 2+2?" }],
});

console.log(res.choices[0].message.content);
// "4"

For Python, use the standard OpenAI library with a custom base_url. See Quick Start for examples.

← Back to PORDL  ·  GitHub  ·  npm