API Documentation

Comprehensive guides and examples for all endpoints.

Code Examples

curl -X POST "https://stapi.pw/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Tell me a fun fact."}]
  }'
import requests
import json

url = "https://stapi.pw/v1/chat/completions"
payload = {
    "model": "gpt-4o",
    "messages": [
        {"role": "user", "content": "Tell me a fun fact."}
    ]
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
}

response = requests.post(url, data=json.dumps(payload), headers=headers)
print(response.json())
const fetch = require('node-fetch');

const url = 'https://stapi.pw/v1/chat/completions';
const data = {
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Tell me a fun fact.' }]
};

fetch(url, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(json => console.log(json))
.catch(error => console.error('Error:', error));

Parameters

  • model - The model to use, e.g. o1-mini or gpt-4o
  • messages - List of messages with role/user content
  • max_tokens - Maximum tokens to generate in the completion
  • temperature - Sampling randomness, 0.0-2.0. Lower = more deterministic
  • top_p - Alternative to temperature, nucleus sampling (0.0-1.0)
  • n - How many completions to generate for each prompt
  • stream - If true, partial messages are sent as data-only server-sent events

Supported Endpoints

  • POST /v1/chat/completions

    Create chat completions with any supported model

  • POST /v1/embeddings

    Create text embeddings for semantic search

  • POST /v1/images/generations

    Generate images from text descriptions

  • POST /v1/audio/speech

    Generate audio from text (Text-to-Speech)

  • POST /v1/audio/transcriptions

    Transcribe audio into text (Speech-to-Text)

  • POST /v1/moderations

    Check if text complies with content policy

Quick Links