Hoveydai

Quickstart

Create an API key, set the Base URL and send your first model request.

Reading time: 2 min

Create an API key

Sign in to the dashboard, open Keys, choose Create key and give it a name, for example "report script". The full key is displayed, but you can copy it again whenever you need to. Keys start with hvd_.

Keep the key out of your code

Keep it in the HOVEYDAI_API_KEY environment variable. If a key leaks, delete it in the dashboard and create a new one.

What you need

No Hoveydai-specific library is needed. An SDK (a client library) can make connecting your app to the API easier, but a plain HTTP request is enough: the request and response format follows the common chat-completions convention, so familiar HTTP clients and libraries work with it. The examples below use requests for Python and the built-in fetch for JavaScript, and the curl tab shows the raw request.

pip install requests

Send your first request

Two values decide which API you connect to and as whom: the Base URL and the key. Everything else is an ordinary JSON request to POST /chat/completions.

import os import requests BASE = "https://api.hoveydai.ir/v1"API_KEY = os.environ["HOVEYDAI_API_KEY"] reply = requests.post(    f"{BASE}/chat/completions",    headers={"Authorization": f"Bearer {API_KEY}"},    json={        "model": "MODEL_ID",        "messages": [{"role": "user", "content": "Hello! Introduce yourself in one sentence."}],    },    timeout=60,)reply.raise_for_status()print(reply.json()["choices"][0]["message"]["content"])

Replace MODEL_ID with the id of one of the models; the list is on models and prices and in Models. If the answer prints, everything works.

Stream the answer

To show the answer while it is being written, add "stream": True to the body, pass stream=True to requests.post and read the data: lines. The stream ends with data: [DONE].

Python
import json payload = {    "model": "MODEL_ID",    "messages": [{"role": "user", "content": "Write a two-line poem."}],    "stream": True,}with requests.post(    f"{BASE}/chat/completions",    headers={"Authorization": f"Bearer {API_KEY}"},    json=payload,    stream=True,    timeout=120,) as reply:    reply.raise_for_status()    for line in reply.iter_lines(decode_unicode=True):        if not line.startswith("data: "):            continue        data = line[len("data: "):]        if data == "[DONE]":            break        chunk = json.loads(data)        print(chunk["choices"][0]["delta"].get("content") or "", end="")

The Streaming page covers usage in the last chunk and errors that arrive mid-stream.

If you get an error

Three common errors on the very first call:

StatusMeansNext step
401The key is wrong or was not sent.Compare the key in your code with the one in the dashboard, and check the Authorization: Bearer ... header.
404We do not know that model id.Copy the id from the model list.
429Too many requests in a short time.Wait the number of seconds in Retry-After, then send again.

Every code, its cause and its fix are on the Errors page.

Next

Did this page not help? Tell us.