EN ▾
Open account

OpenAI API Overview and Compatible Alternatives

The OpenAI API became a de facto standard for talking to language models over HTTP. This overview walks through the pieces you will actually use and shows which of them an independent compatible API supports.

Updated

A glowing map of connected pathways converging on a central hub, an overview of API endpoints

Key points

  1. The core is one JSON request: a model name plus a list of role-tagged messages.
  2. A compatible API supports chat completions, responses, model listing, streaming, tools and JSON mode.
  3. Images, audio, embeddings and fine-tuning are not part of this text-only service.
  4. Usage is billed per token, with a balance header on each response.

The shape of the API

This open ai api overview starts with the one idea everything else hangs on. You send an HTTPS POST with a JSON body. The body names a model and carries a list of messages, each with a role: system for standing instructions, user for the person's input, assistant for earlier replies, and tool for results of function calls. The server returns the model's next message plus a record of how many tokens it used.

The model keeps no memory between requests. If you want a conversation, your code resends the earlier messages each time. That detail explains both how chat apps work and why long conversations cost more per turn, since every resent message counts as input.

It helps to picture the flow as a loop. Your code builds the messages list, sends it, reads the reply, appends that reply to the list as an assistant message, adds the next user message, and sends the whole list again. A chat window, a roleplay bot and a coding helper all run this same loop, and the differences lie in the system message you start with and the settings you pass. Once this loop is clear, the rest of the API reads as options layered on top of it.

Roles also give you a place to put rules. A system message such as "Answer in British English and keep replies under 120 words" applies to the whole conversation, which is cheaper and more reliable than repeating the instruction inside every user message.

Endpoints you will meet

Three endpoints cover most text work, and an independent compatible API can offer the same ones.

EndpointPurposeSupported here
POST /v1/chat/completionsSend messages, get the next replyYes
POST /v1/responsesNewer request format for text generationYes
GET /v1/modelsList the model IDs your key can useYes
Image, audio and video generationMedia outputNo
EmbeddingsVectors for searchNo
Fine-tuningTraining on your dataNo

Larger platforms offer more product areas than text. This service is text only, so if you need embeddings for search, use a separate source for them and keep chat on this endpoint.

A request, line by line

Here is a complete chat completions call with the parameters people change most often.

curl https://api.uncensoredaiopen.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [
      {"role": "system", "content": "You write short, vivid scene descriptions."},
      {"role": "user", "content": "Describe a night market in the rain."}
    ],
    "temperature": 0.8,
    "top_p": 0.95,
    "max_tokens": 300,
    "stop": ["###"],
    "seed": 42
  }'
  • temperature and top_p control randomness. Lower values give steadier answers.
  • max_tokens caps the reply length. It is optional here; without it the completion can use the rest of the 100,000-token window.
  • stop ends generation when a string appears.
  • seed asks for repeatable sampling where possible.
  • Frequency and presence penalties discourage repetition and are passed through.

The reply carries choices[0].message.content with the text and a usage block with prompt, completion and total token counts.

Streaming, tools and JSON mode

Streaming

Set stream: true and the server sends Server-Sent Events, one small chunk of text at a time, so users see words appear instead of waiting for the full answer. The final chunk includes usage.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://api.uncensoredaiopen.com/v1",
)

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

Tool calling

You describe functions in the tools parameter. When the model decides one is needed, it returns a tool_calls entry with the function name and JSON arguments. Your code runs the function and sends the result back as a message with role: "tool". tool_choice lets you force or forbid a call. Streamed tool calls arrive in pieces that you assemble.

JSON mode

Pass response_format: {"type": "json_object"} and the reply is a JSON object, which suits extraction and structured output. Mention JSON in your prompt as well, so the model knows what shape you want.

Reading a response

A non-streaming chat completion returns one JSON object. The fields you will touch most are few, and knowing them saves time when you debug.

  • id and object identify the response. Log the id along with the X-Request-Id header.
  • choices is a list. Normally it holds one item, and choices[0].message.content is the reply text.
  • choices[0].finish_reason says why generation ended. stop means the model finished or hit a stop string, and length means it ran out of allowed tokens.
  • choices[0].message.tool_calls appears when the model asks you to run a function.
  • usage holds prompt_tokens, completion_tokens and total_tokens, which are the numbers billing uses.

A reply cut off mid-sentence almost always shows finish_reason of length. Raise max_tokens or remove it, because here it is optional and the completion can use whatever is left of the window.

Chat completions or responses

Both endpoints reach the same model. Chat completions is the safest choice if your code or a third-party tool already speaks it, since nearly every client library and front end supports it. The responses endpoint suits code written against the newer format. Pick one per project and keep it consistent, so you only have one set of response shapes to handle. For a fixed list of parameters and examples of each, keep the docs open next to your editor.

Limits, errors and billing signals

A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60. The maximum request body is 8 MB. Every response carries X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency.

Going over a limit returns HTTP 429, with error code rate_limited for requests per minute or concurrency for too many requests at once. A temporary overload also returns 429 with Retry-After: 5. A streamed request keeps its concurrency slot until the stream finishes. To check credit without sending a prompt, call GET /v1/balance or the OpenAI-style /v1/dashboard/billing/credit_grants.

Price and where to go next

Billing is per token: $0.15 per 1M input tokens and $0.50 per 1M output tokens, paid from prepaid credit. A request with 3,000 tokens in and 700 out costs $0.00045 plus $0.00035, which is $0.0008. Failed or refused requests are not charged. See the pricing page for top-up amounts and bonuses.

To try it, claim the trial on the API key page and read the documentation. Before you ship anything to real users, work through the production checklist.

One more habit pays off early: log the usage block of every response next to the request id. After a day of real traffic you will know your average input and output sizes, and those two numbers are all you need to forecast spend at the rates above.

Questions and answers

What is the difference between chat completions and the responses endpoint?

Both generate text from a model. Chat completions is the long-established messages format, while responses is a newer request format. This API accepts both.

Does a compatible API keep my conversation history?

No. Each request is independent, so your code sends the earlier messages every time you want context.

Can I use embeddings or image generation here?

No. This service is text only and has no embeddings, image, audio or video endpoints, and no fine-tuning.

How big can a request be?

The context window is 100,000 tokens for prompt plus completion, and the request body can be up to 8 MB.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Start with trial credit

Email and password, key on screen right away.