Skip to main content

Documentation Index

Fetch the complete documentation index at: https://doc.hitopen.com/llms.txt

Use this file to discover all available pages before exploring further.

Newapi is compatible with the OpenAI API format, so any OpenAI client library works out of the box. This guide walks you through generating an API token and making your first chat completion request.

Prerequisites

  • A Newapi account with access to the console
  • The base URL of your Newapi instance (e.g., https://your-newapi-domain.com)

Step 1: Create an API token

1

Open Token Management

Log in to the Newapi console and navigate to Token Management in the sidebar.
2

Create a new token

Click New Token, give it a name, and optionally set a quota limit or expiration date.
3

Copy your key

Copy the generated API key (it starts with sk-). Store it securely — you won’t be able to view it again.

Step 2: Send a chat completion

Replace YOUR_API_KEY and YOUR_NEWAPI_BASE_URL with your actual values.
curl -X POST "https://YOUR_NEWAPI_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Hello! What can you help me with?"}
    ]
  }'

Expected response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1715000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I can help you with a wide range of tasks..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 42,
    "total_tokens": 57
  }
}

Step 3: List available models

To see which models are available on your Newapi instance:
curl "https://YOUR_NEWAPI_BASE_URL/v1/models" \
  -H "Authorization: Bearer YOUR_API_KEY"
The models available depend on which channels have been configured in your Newapi instance. Contact your administrator if you don’t see the model you need.

Next steps