๐Ÿค– GPT-OSS 2T API

Free, rate-limited AI API powered by GPT-OSS

โœจ Model: gpt-oss:latest
๐ŸŒ Global Edge Network
๐Ÿš€ Cloudflare Pages
๐ŸŽ‰ API is Live! Start making requests immediately โ€” no API key required.

๐Ÿ“ก Base URL

https://gpt-oss-2t.pages.dev/api/gpt-oss-2t

โšก Quick Start

JavaScript (Fetch API)

const response = await fetch('https://gpt-oss-2t.pages.dev/api/gpt-oss-2t', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    messages: [
      { role: 'user', content: 'Hello! Who created you?' }
    ],
    stream: false,
    temperature: 0.8
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);

JavaScript (Streaming)

const response = await fetch('https://gpt-oss-2t.pages.dev/api/gpt-oss-2t', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    messages: [
      { role: 'user', content: 'Tell me a short story!' }
    ],
    stream: true
  })
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  
  const chunk = decoder.decode(value);
  const lines = chunk.split('\n').filter(line => line.trim());
  
  for (const line of lines) {
    if (line.startsWith('data: ')) {
      const data = line.slice(6);
      if (data === '[DONE]') continue;
      
      try {
        const parsed = JSON.parse(data);
        const content = parsed.choices[0]?.delta?.content || '';
        process.stdout.write(content); // Stream to console
      } catch (e) {}
    }
  }
}

Python

import requests

response = requests.post(
    'https://gpt-oss-2t.pages.dev/api/gpt-oss-2t',
    json={
        'messages': [
            {'role': 'user', 'content': 'Hello! Who created you?'}
        ],
        'stream': False,
        'temperature': 0.8
    }
)

data = response.json()
print(data['choices'][0]['message']['content'])

cURL

curl -X POST https://gpt-oss-2t.pages.dev/api/gpt-oss-2t \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "Hello! Who created you?"}
    ],
    "stream": false,
    "temperature": 0.8
  }'

๐Ÿ“ Request Parameters

Parameter Type Required Description
messages array โœ… Yes Array of message objects with role and content
stream boolean โŒ No Enable streaming responses (default: true)
temperature number โŒ No Sampling temperature 0.0-2.0 (default: 0.8)
max_tokens number โŒ No Maximum tokens to generate (default: -1 = unlimited)
top_p number โŒ No Nucleus sampling parameter (default: 0.9)

๐Ÿ”’ Rate Limits

โš ๏ธ Per-IP Rate Limiting Enforced
  • Maximum 2 requests per second per IP
  • Minimum 500ms delay between requests
  • Requests are queued and processed sequentially per IP

๐Ÿ“Š Response Format

Non-Streaming Response

{
  "id": "chatcmpl-xyz",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "gpt-oss:latest",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I was created by Riste Stev..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 50,
    "total_tokens": 70
  }
}

Streaming Response (SSE)

data: {"id":"chatcmpl-xyz","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: {"id":"chatcmpl-xyz","choices":[{"delta":{"content":" there"},"index":0}]}

data: [DONE]

๐Ÿšจ Error Responses

{
  "error": "Missing messages array"
}

๐Ÿค– AI Implementation Prompt

Copy this prompt and paste it into any AI assistant (ChatGPT, Claude, etc.) to automatically implement this API:

I need you to integrate the GPT-OSS 2T API into my application.

API Endpoint: https://gpt-oss-2t.pages.dev/api/gpt-oss-2t
Method: POST

Request format (JSON):
{
  "messages": [
    {"role": "user", "content": "your message here"}
  ],
  "stream": true,  // or false for non-streaming
  "temperature": 0.8,
  "max_tokens": -1,
  "top_p": 0.9
}

Requirements:
1. Create a chat interface with a text input and send button
2. Display user messages and AI responses in a conversation view
3. Support streaming responses (show AI response word-by-word as it arrives)
4. Handle the SSE stream format: "data: {json}\n\n" and stop on "data: [DONE]"
5. Add error handling for network issues and rate limits
6. Show a loading indicator while waiting for responses
7. Make the UI responsive and user-friendly

The API:
- Uses OpenAI-compatible format
- Has rate limiting: max 2 req/sec per IP, 500ms min gap between requests
- Supports both streaming and non-streaming responses
- No API key required
- CORS enabled for browser requests

Please implement this with clean, production-ready code.

๐Ÿงช Test the API

Health Check: GET https://gpt-oss-2t.pages.dev/api/gpt-oss-2t

Returns API status, model info, and rate limit details.

๐Ÿ’ก Example Use Cases

๐Ÿ› ๏ธ Technical Details

Infrastructure:
  • Hosted on Cloudflare Pages (global edge network)
  • Automatic retry with exponential backoff (3 attempts)
  • Per-IP sequential request queuing
  • Built-in rate limiting and throttling
  • System prompt auto-injection with current date/time

๐Ÿ“œ License & Attribution

This API is powered by GPT-OSS, created by Riste Stev.

Please use responsibly and respect the rate limits. This is a free service provided for educational and development purposes.