EN ▾
https://api.textspolitical.com/v1$0.15 per 1M input tokens$0.50 Output tokens / 1M100,000 token context

Quickstart: First API Call

Generate uncensored political texts with a single API call using our OpenAI-compatible endpoint. This guide walks you through authentication, sending requests, and handling streaming responses for high-volume outreach.

Base URL and Authentication

Your API key authenticates every request. You must include it in the Authorization header as a Bearer token. Use the base URL https://api.textspolitical.com/v1 for all endpoints. This URL works with standard OpenAI SDKs and any compatible client. Your key grants access to the uncensored model without subscription fees.

Sending Your First Chat Completion

Send a POST request to /v1/chat/completions with your prompt. The model id is uncensored. It responds with text without filtering lawful adult content. This direct response format is ideal for generating bulk political messages. Use the following example to verify your connection.

curl https://api.textspolitical.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "List three benefits of digital surveys for campaign outreach"}]
  }'

Using Python and Node SDKs

Install the official OpenAI library to simplify integration. Pass your base URL and API key during initialization. The Python SDK handles JSON serialization automatically. The Node SDK provides similar functionality for JavaScript environments. Both tools support the required parameters like temperature and top_p.

from openai import OpenAI

client = OpenAI(base_url="https://api.textspolitical.com/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.textspolitical.com/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

Streaming Responses with SSE

Enable streaming by setting stream: true. You receive Server-Sent Events (SSE) as tokens generate. This reduces perceived latency for long political texts. Token usage details appear in the final chunk. This method is essential for real-time chat interfaces or live text generation.

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Function Calling and JSON Mode

Use response_format set to json_object for structured data. Function calling allows the model to output defined tools. This is useful for survey data or tagged political messages. You can also set tool_choice to force specific behaviors. Ensure your schema matches the expected output format.

Rate Limits and Constraints

You are limited to 300 requests per minute per key. Concurrency is capped at 8 simultaneous requests. Each request body must stay under 8 MB. The context window supports 100,000 tokens total. Errors and refusals do not consume credit. Use these limits to design your retry logic effectively.

Common questions

Why am I getting a 401 error?

A 401 error indicates an invalid or missing API key. Check your Authorization header for the correct Bearer token. Ensure your key was generated from your dashboard and has not been revoked.

What happens if I run out of credit?

You will receive a 402 error when your prepaid balance is exhausted. Credits never expire, so you can top up anytime via crypto. Errors during request processing do not deduct from your balance.

How do I handle rate limits?

You are limited to 300 requests per minute and 8 concurrent connections. Implement exponential backoff in your client to handle 429 Too Many Requests responses. Avoid sending bursts that exceed the concurrency cap to prevent temporary blocks.

Access your key in one step

Register, copy your key, update the endpoint URL. That’s it.

Open account