USA Tech Solutions AI API

API reference

The API is a drop-in replacement for the OpenAI REST API. Point any OpenAI SDK at our base URL, use your usk_live_… key, and pick a model id from /v1/models.

Base URL and authentication

https://api.usatechsolution.ai/v1

Custom domain api.usatechsolution.ai is coming; the Netlify URL will keep working.

Send your key in the Authorization header (the x-api-key header is accepted too):

Authorization: Bearer usk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Create keys in the dashboard. Keys are shown once and stored hashed; rotate or revoke them any time.

Keys: token vs monthly

TypeBilled fromWhen it stopsBest for
Token keyPrepaid credits, per request, at the per-token USD prices402 insufficient_credits when your balance is $0. The balance can never go negative.Pay-as-you-go, bursty workloads, any model
Monthly keyYour subscription's monthly weighted-token quota (only models included in the plan)402 quota_exceeded (with the reset date) when the quota is used up — unless overflow is enabled, in which case the request is billed from prepaid credits instead. 402 subscription_inactive once a past-due subscription passes its 3-day grace period.Steady workloads with predictable monthly cost

Both key types can carry an optional model allowlist (403 model_not_allowed otherwise) and an expiry date (401 key_expired after it).

Weighted tokens

Monthly quotas count weighted tokens so that expensive models use quota faster:

weighted = prompt_tokens × weight + completion_tokens × 3 × weight

Weights per model: Opus-class 5×, Fable 2×, other chat models 1×, embeddings 0.2×. Reasoning tokens count as completion tokens. The exact weight for each model is shown in the model catalog.

GET /v1/models

Lists the models that are live right now with our prices. With a key, each entry also tells you whether it is included in your plan.

curl https://api.usatechsolution.ai/v1/models \
  -H "Authorization: Bearer $USATECH_API_KEY"
{
  "object": "list",
  "data": [
    {
      "id": "gpt-chat-latest",
      "object": "model",
      "owned_by": "openai",
      "pricing": { "input_usd_per_million": 6, "output_usd_per_million": 25, "currency": "USD" },
      "context_window": 128000,
      "included_in_plan": true
    }
  ]
}

POST /v1/chat/completions

Same request and response shape as OpenAI. Supported fields: model, messages, max_tokens (or max_completion_tokens), temperature, top_p, stop, stream, stream_options, tools, tool_choice, response_format, seed, user, reasoning_effort. n must be 1. max_tokens is clamped to the key's cap (8,192 by default).

curl https://api.usatechsolution.ai/v1/chat/completions \
  -H "Authorization: Bearer $USATECH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-chat-latest",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Write a haiku about Mumbai rain."}
    ],
    "max_tokens": 200
  }'

The response includes usage.prompt_tokens and usage.completion_tokens, which are exactly what you are billed for. Some models (e.g. gpt-chat-latest) only accept the default sampling values; the gateway drops temperature/top_p for them instead of failing. Reasoning models (Grok, Kimi) may return a non-standard reasoning_content field.

Streaming

Set "stream": true to receive server-sent events (data: {chunk} lines ending with data: [DONE]). Add "stream_options": {"include_usage": true} to get a final chunk with token usage.

curl -N https://api.usatechsolution.ai/v1/chat/completions \
  -H "Authorization: Bearer $USATECH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"kimi-k3.1-pro","stream":true,"stream_options":{"include_usage":true},
       "messages":[{"role":"user","content":"Count to 5"}]}'

Streams can run for up to 60 seconds; keep max_tokens reasonable for very long generations.

Tool calling

Pass OpenAI-style tools and tool_choice; the model returns tool_calls with finish_reason: "tool_calls". Feed results back as role: "tool" messages.

{
  "model": "gpt-chat-latest",
  "messages": [{"role": "user", "content": "What is the weather in Delhi?"}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get current weather for a city",
      "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
    }
  }],
  "tool_choice": "auto"
}

POST /v1/embeddings

curl https://api.usatechsolution.ai/v1/embeddings \
  -H "Authorization: Bearer $USATECH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "text-embedding-3-small", "input": ["hello world", "namaste duniya"]}'

input is a string or an array of up to 2,048 strings. Returns 1,536-dimensional vectors; billed on usage.prompt_tokens only.

GET /v1/usage

Returns the calling key's standing: its type, remaining prepaid credits, monthly quota used/remaining and the current period, plus this period's request count and spend. Useful for building "credits left" indicators into your app.

curl https://api.usatechsolution.ai/v1/usage \
  -H "Authorization: Bearer $USATECH_API_KEY"

SDK examples

pip install openai

from openai import OpenAI

client = OpenAI(
    base_url="https://api.usatechsolution.ai/v1",
    api_key="usk_live_...",
)

resp = client.chat.completions.create(
    model="gpt-chat-latest",
    messages=[{"role": "user", "content": "Explain UPI in one paragraph."}],
    max_tokens=300,
)
print(resp.choices[0].message.content)
print(resp.usage)
from openai import OpenAI

client = OpenAI(base_url="https://api.usatechsolution.ai/v1", api_key="usk_live_...")

stream = client.chat.completions.create(
    model="grok-4.7",
    messages=[{"role": "user", "content": "Write a limerick about chai."}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if chunk.usage:
        print("\n", chunk.usage)
npm install openai

import OpenAI from "openai";

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

const resp = await client.chat.completions.create({
  model: "kimi-k3.1-pro",
  messages: [{ role: "user", content: "Summarise the Mahabharata in 3 lines." }],
  max_tokens: 400,
});
console.log(resp.choices[0].message.content, resp.usage);
import OpenAI from "openai";

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

const stream = await client.chat.completions.create({
  model: "gpt-chat-latest",
  messages: [{ role: "user", content: "Count to 10 slowly." }],
  stream: true,
  stream_options: { include_usage: true },
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
  if (chunk.usage) console.log("\n", chunk.usage);
}

LangChain

Use the OpenAI chat model class with base_url and your key. Works with agents, chains and LCEL unchanged.

pip install langchain-openai

from langchain_openai import ChatOpenAI, OpenAIEmbeddings

llm = ChatOpenAI(
    model="gpt-chat-latest",
    base_url="https://api.usatechsolution.ai/v1",
    api_key="usk_live_...",
    max_tokens=500,
)
print(llm.invoke("Give me three startup ideas for Nairobi.").content)

emb = OpenAIEmbeddings(
    model="text-embedding-3-small",
    base_url="https://api.usatechsolution.ai/v1",
    api_key="usk_live_...",
)
print(len(emb.embed_query("hello")))
npm install @langchain/openai

import { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "grok-4.7",
  apiKey: process.env.USATECH_API_KEY,
  configuration: { baseURL: "https://api.usatechsolution.ai/v1" },
  maxTokens: 500,
});
const res = await llm.invoke("Give me three startup ideas for Dhaka.");
console.log(res.content);

const emb = new OpenAIEmbeddings({
  model: "text-embedding-3-small",
  apiKey: process.env.USATECH_API_KEY,
  configuration: { baseURL: "https://api.usatechsolution.ai/v1" },
});
console.log((await emb.embedQuery("hello")).length);

Error codes

Errors use the OpenAI envelope: {"error": {"message", "type", "param", "code"}}.

HTTPcodeMeaning / what to do
401invalid_api_keyMissing, malformed, revoked or unknown key. Check the Authorization header.
401key_expiredThe key passed its expiry date. Create or rotate a key.
402insufficient_creditsToken key (or overflow) with a $0 balance. Add credits.
402quota_exceededMonthly key used its quota; the message includes the reset date. Enable overflow, upgrade, or wait.
402subscription_inactiveMonthly key whose subscription is cancelled or more than 3 days past due. Renew on the Billing page.
403key_suspendedKey or account suspended (abuse or payment issue). Contact support.
403model_not_allowedThe model is not in the key's allowlist or not included in the plan for a monthly key.
429rate_limit_exceededPer-minute limit, daily cap or fair-use cap reached. Honour retry-after.
400model_not_foundUnknown or not-yet-available model id. Use one from /v1/models.
400invalid_request_errorMalformed body (e.g. missing messages).
502upstream_errorThe model provider failed; nothing was billed. Retry.

Rate limits and caps

  • Token keys: 60 requests/min and a $20/day spend cap per key by default.
  • Monthly keys: the plan's requests/min (60–300) and weighted-tokens/day fair-use cap.
  • max_tokens is clamped to 8,192 per request by default.
  • Need more? Email anylohar49@gmail.com — limits are adjustable per key.

Request metadata (timestamps, token counts, model, IP) is logged for billing and abuse prevention. Prompt and response content is not stored. See the Terms and Acceptable Use Policy.