AnyInt Docs
API Reference

OpenAI Compatible API

Use this route when you want the fastest path to production or when your application already speaks the OpenAI Chat Completions format.

Use this route when you want the fastest path to production or when your application already speaks the OpenAI Chat Completions format.

Base URL

https://api.anyint.ai/openai/v1

Published route

POST /chat/completions

Full URL:

https://api.anyint.ai/openai/v1/chat/completions

Authentication

Authorization: Bearer <ANYINT_API_KEY>
Content-Type: application/json

When to use this route

  • You already use the OpenAI Python or JavaScript SDK
  • You want one stable chat entrypoint for multiple model families
  • You want SSE streaming with minimal integration work

If you need Gemini-native request bodies or Anthropic-specific guides such as token counting, use those provider-compatible pages directly.

If a client specifically requires OpenAI Responses API wiring, use OpenAI Responses API. For embeddings, image generation, audio, files, batches, assistants, threads, and videos, see OpenAI Extended Endpoints.

Core request shape

FieldTypeRequiredMeaningExample
modelstringYesModel ID to use for the request. Fetch this from Models API instead of guessing.claude-sonnet-4-6
messagesarrayYesOrdered conversation turns in OpenAI Chat Completions format.[{"role":"user","content":"Hello"}]
streambooleanNoSet true to receive SSE chunks; omit or set false for a single JSON response.true
max_tokensintegerNoMaximum number of output tokens the model should generate.512
temperaturenumberNoControls randomness. Lower values are more deterministic; higher values are more varied.0.7
top_pnumberNoNucleus sampling control. Use either temperature or top_p tuning first; avoid changing both without a reason.1
stopstring or arrayNoStop sequence or sequences that end generation early.["\nUser:"]
toolsarrayNoOpenAI-compatible tool definitions for model tool calling when supported by the selected model.[{"type":"function",...}]
tool_choicestring or objectNoControls whether the model may call tools, must call a specific tool, or should not call tools."auto"
presence_penaltynumberNoPenalizes new tokens based on whether they already appeared in the text.0
frequency_penaltynumberNoPenalizes repeated tokens based on frequency.0
userstringNoEnd-user identifier for your own abuse monitoring or request tracing. Do not send private personal data unless your policy allows it.user_123

The current published schema documents the minimum request body needed to get a completion working. If your client already uses other OpenAI-compatible fields, validate them against the target model before relying on them in production.

Message fields

FieldTypeRequiredMeaningExample
rolestringYesMessage author. Common values are system, user, assistant, and tool.user
contentstring or arrayUsuallyText content or multimodal content blocks when supported by the selected model.Explain AnyInt in one sentence.
namestringNoOptional participant name used by some OpenAI-compatible clients.planner
tool_call_idstringTool responses onlyAssociates a tool response with a prior tool call.call_123

Multimodal message blocks

For image-capable chat models, send images in messages[].content[] with OpenAI-compatible content blocks. This is the recommended shape when you want a single AnyInt chat endpoint and need to include a reference image.

This page documents image input for the OpenAI-compatible chat route. For video or file understanding, use the Gemini-native fileData.fileUri shape on the Gemini Compatible API page instead of inventing OpenAI-style video_url or file blocks.

FieldTypeRequiredMeaningExample
messages[].content[]arrayYesOrdered content blocks in one message. Include text instructions and one or more images.[{"type":"text",...},{"type":"image_url",...}]
content[].typestringYesBlock type. Use text for instructions and image_url for image inputs.image_url
content[].textstringFor text blocksText prompt or instruction.Describe this reference image.
content[].image_url.urlstringFor image_url blocksPublic HTTPS image URL or a data:image/...;base64,... data URL. Public HTTPS URLs are best for production; data URLs are useful for local files.https://your-domain.com/reference.png
curl https://api.anyint.ai/openai/v1/chat/completions \
  -H "Authorization: Bearer $ANYINT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.1-flash-image-preview",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Use this reference image and describe the product style in one sentence."
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://your-domain.com/reference.png"
            }
          }
        ]
      }
    ]
  }'

Use a URL that the upstream provider can fetch. Some providers reject images that are blocked by robots.txt, require cookies, redirect through private CDNs, or are not valid image bytes.

For local files, do not send the filesystem path. Encode the image and pass a data URL instead:

IMAGE_DATA="$(base64 -i ./reference.png | tr -d '\n')"

Then set image_url.url to:

data:image/png;base64,$IMAGE_DATA

Use this format when the image starts as a local file and you do not want to upload it first. Very large images are usually better handled by uploading them to object storage or a CDN and passing a public HTTPS URL.

Response fields

FieldMeaning
idResponse identifier returned by the compatible API path
objectResponse object type, such as chat.completion or chat.completion.chunk
createdUnix timestamp for response creation
modelModel that handled the request
choices[]Generated message or stream delta choices
choices[].message.contentGenerated text for non-streaming responses
choices[].delta.contentIncremental text for streaming responses
usage.prompt_tokensInput tokens counted by the provider when available
usage.completion_tokensOutput tokens counted by the provider when available
usage.total_tokensTotal tokens counted by the provider when available

cURL example

curl https://api.anyint.ai/openai/v1/chat/completions \
  -H "Authorization: Bearer $ANYINT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "stream": true,
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Explain AnyInt in one sentence."}
    ]
  }'

Python example

from openai import OpenAI

client = OpenAI(
    base_url="https://api.anyint.ai/openai/v1",
    api_key="your-anyint-api-key",
)

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    stream=True,
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Explain AnyInt in one sentence."},
    ],
)

for chunk in response:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="")

JavaScript example

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.anyint.ai/openai/v1",
  apiKey: process.env.ANYINT_API_KEY,
});

const stream = await client.chat.completions.create({
  model: "claude-sonnet-4-6",
  stream: true,
  messages: [
    { role: "system", content: "You are a concise assistant." },
    { role: "user", content: "Explain AnyInt in one sentence." },
  ],
});

for await (const chunk of stream) {
  const delta = chunk.choices?.[0]?.delta?.content;
  if (delta) process.stdout.write(delta);
}

Response behavior

  • With stream: true, the route returns SSE chunks
  • The published schema uses chat.completion.chunk style objects
  • Each chunk can contain choices[0].delta.content
  • The stream ends with [DONE]
  • Final usage data can arrive near the end of the stream

Common mistakes

  • Using x-api-key instead of Authorization: Bearer
  • Hardcoding a model ID before checking Models API
  • Treating a partial stream chunk as the final answer
  • Sending a local file path such as /tmp/image.png instead of a public image URL or data URL
  • Sending video files through undocumented OpenAI-style content block types instead of using Gemini-native fileData.fileUri
  • Mixing provider-native request fields into the OpenAI payload without validation
  • Sending bare base64 without the data:image/...;base64, prefix

On this page