> For the complete documentation index, see [llms.txt](https://docs.avis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avis.net/guide/get-started/first-api-call.md). Agents can also search and read this documentation through its [MCP server](https://docs.avis.net/~gitbook/mcp).

# Make your first API call

This guide takes you from no account to a working API request in about five minutes. You'll sign in, add credits, create an API key, choose a model, and send a plain HTTP request. No SDK is needed.

***

## Before you start

You'll need:

* A Google account, or an email address you can receive a code at
* A way to pay through **MoMo** or **VNPAY** (for topping up credits)
* A terminal with `curl`, **or** Python 3 with `requests`, **or** Node.js 18+

***

## Step 1: Sign in

Go to [avis.net](https://www.avis.net) and click **Login**. Sign in with Google or with a one-time email code. If this is your first sign-in, your account is created automatically.

See [How to login/ sign up](https://docs.avis.net/guide/get-started/avis-login-signup.md) for the full walkthrough.

***

## Step 2: Add credits

Requests are paid from a prepaid credit balance. If your balance is zero, the API returns **403 Forbidden**.

Click **Top Up** in the top bar, pick MoMo or VNPAY, enter an amount, and pay. A small amount is enough for testing.

See [How to top up your balance](https://docs.avis.net/guide/get-started/avis-topup.md).

***

## Step 3: Create an API key

In the Console sidebar, open **API Key** and click **Create New API Keys**. Give the key a name such as `local-testing` and set a low **daily spend limit** while you experiment. Copy the key as soon as it's shown, because you won't be able to see it again.

Save it as an environment variable so it never appears in your code:

```bash
# macOS / Linux
export AVIS_API_KEY="paste-your-key-here"

# Windows (PowerShell)
$env:AVIS_API_KEY="paste-your-key-here"
```

See [How to get API Key](https://docs.avis.net/guide/get-started/avis-api-key.md).

***

## Step 4: Choose a model

Open **Models** in the Console sidebar and find the model you want. Copy its **Model ID** exactly as shown. You'll pass it as the `model` value in your request.

**Tip:** If you're not sure which model to pick, try a few in the [Playground](https://github.com/coin98/documentation/tree/docs_avis/guide/get-started/playground.md) first. No code is needed, and you only pay for what you generate.

***

## Step 5: Send your first request

Every AVIS request is a regular HTTPS `POST` with a JSON body. You don't need to install an SDK. Send your key in the `Authorization` header, and put the Model ID you copied in Step 4 in `model`.

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://api.avis.net/api/openai/v1/chat/completions \
  -H "Authorization: Bearer $AVIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1-mini",
    "messages": [{"role": "user", "content": "Say hello in Vietnamese."}]
  }'
```

**Note:** This command is written for macOS, Linux, and Git Bash. In Windows PowerShell, use the Python or JavaScript tab instead.
{% endtab %}

{% tab title="Python" %}

```python
import os
import requests

response = requests.post(
    "https://api.avis.net/api/openai/v1/chat/completions",
    headers={"Authorization": f"Bearer {os.environ['AVIS_API_KEY']}"},
    json={
        "model": "openai/gpt-4.1-mini",  # replace with a Model ID from the Models page
        "messages": [{"role": "user", "content": "Say hello in Vietnamese."}],
    },
)
response.raise_for_status()

print(response.json()["choices"][0]["message"]["content"])
```

If you see `ModuleNotFoundError: No module named 'requests'`, run `pip install requests`.
{% endtab %}

{% tab title="JavaScript" %}
Save this as `hello.mjs` and run `node hello.mjs`. Node.js 18+ includes `fetch`, so there's nothing to install.

```javascript
const response = await fetch('https://api.avis.net/api/openai/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.AVIS_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'openai/gpt-4.1-mini', // replace with a Model ID from the Models page
    messages: [{ role: 'user', content: 'Say hello in Vietnamese.' }],
  }),
})

if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`)

const data = await response.json()
console.log(data.choices[0].message.content)
```

{% endtab %}
{% endtabs %}

**Tip:** This endpoint works with **every** model in the catalogue, not only OpenAI models. To try Claude or Gemini, change only the `model` value, for example `anthropic/claude-sonnet-4-5`.

If you get a reply, your setup works.

***

## Step 6: Check what it cost

Open **Dashboard** in the Console sidebar. Your request appears under **Total requests**, and its cost appears under **Total cost**, broken down by model. The dashboard refreshes automatically every 30 minutes, so a brand-new request can take a while to appear.

To check usage from code instead, call `GET /api/compat/v1/usage`. See [Usage](https://docs.avis.net/api-reference/introduction/use.md).

***

## Already using an SDK?

If your app already uses the official OpenAI, Anthropic, or Gemini SDK, you don't need to rewrite anything. Change the **API key** and the **base URL**, and keep the rest of your code.

{% tabs %}
{% tab title="OpenAI SDK" %}

```typescript
const client = new OpenAI({
  apiKey: process.env.AVIS_API_KEY,
  baseURL: 'https://api.avis.net/api/openai/v1',
})
```

```python
client = OpenAI(
    api_key=os.environ["AVIS_API_KEY"],
    base_url="https://api.avis.net/api/openai/v1",
)
```

{% endtab %}

{% tab title="Anthropic SDK" %}

```typescript
const client = new Anthropic({
  apiKey: process.env.AVIS_API_KEY,
  baseURL: 'https://api.avis.net/api/anthropic',
})
```

{% endtab %}

{% tab title="Gemini SDK" %}

```typescript
const ai = new GoogleGenAI({
  apiKey: process.env.AVIS_API_KEY,
  httpOptions: { baseUrl: 'https://api.avis.net/api/gemini' },
})
```

**Note:** Don't add `/v1beta` to the base URL. The Gemini SDK adds it for you.
{% endtab %}
{% endtabs %}

Full details: [OpenAI Compatibility](https://docs.avis.net/api-reference/introduction/openai-compatibility.md), [Anthropic Compatibility](https://docs.avis.net/api-reference/introduction/anthropic-compatibility.md), [Gemini Compatibility](https://docs.avis.net/api-reference/introduction/gemini-compatibility.md).

***

## Troubleshooting

| Error                     | What it means                                         | What to do                                                                                                                  |
| ------------------------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| **401 Unauthorized**      | The key is missing, mistyped, or deleted              | Make sure `AVIS_API_KEY` is set in the same terminal you run the code from, and the header is `Authorization: Bearer <key>` |
| **400 Bad Request**       | The model ID is wrong, or the request body is invalid | Copy the model ID again from the **Models** page and check that your JSON is valid                                          |
| **403 Forbidden**         | Your credit balance is zero or below                  | Top up your balance                                                                                                         |
| **429 Too Many Requests** | This key has reached one of its spend limits          | Raise the limit on the **API Key** page, or wait for the daily/weekly/monthly window to reset                               |
| **502 / 503**             | The upstream model provider is having problems        | Retry after a short wait, or switch to another model                                                                        |

See [Errors](https://docs.avis.net/api-reference/introduction/errors.md) for the full list.

***

## What's Next

* Generate images, video, or audio, see [Endpoints](https://github.com/coin98/documentation/tree/docs_avis/api-reference/endpoints.md).
* Stream responses token by token, see [Streaming](https://docs.avis.net/api-reference/introduction/streaming.md).
* Use AVIS inside Claude Code, Codex CLI, or your editor, see [Integrations](https://docs.avis.net/integrations/overview.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avis.net/guide/get-started/first-api-call.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
