USA Inference Labs

API reference

Reference for the USA Inference Labs model listing and chat completions endpoints, including Bearer authentication, curl examples, and a live API playground.

The base URL is https://api.usainferencelabs.com/v1. Both endpoints require a USA Inference Labs API key.

Try the API

Use your USA Inference Labs API key to send a live request and inspect the JSON response.

API operation
POST/v1/chat/completions

Kept in this page and forwarded with each request.

Chat request settings

1–256

Up to 4,000 characters.

Playground output
import os
from openai import OpenAI

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

completion = client.chat.completions.create(
    model="primary-v1",
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
    max_tokens=64,
)
print(completion.choices[0].message.content)

Authentication

Send your key in the Authorization header with the Bearer scheme. For scripts and applications, read the key from an environment variable or secret manager.

Authorization: Bearer <USA_INFERENCE_LABS_API_KEY>

List models

GET /v1/models

Returns an object with a data array. Each entry has an id you can use as the model in a completion request.

curl --fail-with-body --silent --show-error \
  https://api.usainferencelabs.com/v1/models \
  -H "Authorization: Bearer ${USA_INFERENCE_LABS_API_KEY}"

Create a chat completion

POST /v1/chat/completions
Content-Type: application/json

Send a model alias and one or more messages. This example requests a non-streaming response.

Field used in this exampleTypeDescription
modelstringAn alias returned by the model list, such as coder-v1
messagesarrayConversation messages. This example sets role to user and uses a text content value
max_tokensintegerUpper bound on generated tokens. Use a small value when testing
streambooleanSet to false to receive a JSON completion
curl --fail-with-body --silent --show-error \
  https://api.usainferencelabs.com/v1/chat/completions \
  -H "Authorization: Bearer ${USA_INFERENCE_LABS_API_KEY}" \
  -H "Content-Type: application/json" \
  --data '{
    "model": "coder-v1",
    "messages": [
      {"role": "user", "content": "Say hello in one sentence."}
    ],
    "max_tokens": 32,
    "stream": false
  }'

Read the generated text from choices[0].message.content. A response includes fields like these.

{
  "model": "coder-v1",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hello. How can I help?" },
      "finish_reason": "stop"
    }
  ]
}

Handle errors

HTTP statusWhat to check
400Check that the JSON is valid and includes the fields for the operation
401Check that the Authorization header contains a valid Bearer key
429Reduce request volume and back off before retrying
5xxRetry a temporary failure with bounded backoff. Keep the request ID for support if one was returned

See the Python quickstart for an SDK example and the security and data handling overview for credential and request-handling guidance.