Skip to main content

Making Your First API Request

This guide walks through a first successful call to the embeddings API.

For Python, the recommended path is the official inertialai-python client. A cURL example is included later as a raw HTTP reference.

Before you start

You should already have:

The basics

API base: https://inertialai.com/api/v1

Authentication: Send your API key in the Authorization header (details in Authentication):

Authorization: Bearer <YOUR_API_KEY>

Step 1: Set your API key as an environment variable

If you haven't already, set your API key as an environment variable.

export INERTIALAI_API_KEY="your_api_key_here"

Step 2: Install the official Python SDK

python -m pip install inertialai-python

Step 3: Generate an embedding with Python

from inertialai_python import EmbeddingModel, InertialAI
from inertialai_python.types import EmbeddingMultiModalInput

with InertialAI() as client:
response = client.embeddings.create(
model=EmbeddingModel.INERTIAL_EMBED_ALPHA,
input=[
EmbeddingMultiModalInput(
text="The accelerometer measured 9.81 m/s^2 downward acceleration."
)
],
)

print("model:", response.model)
print("num_embeddings:", len(response.data))
print("embedding_length:", len(response.data[0].embedding))

What to expect on success:

  • response.data contains one EmbeddingData object per input item
  • response.data[0].embedding is the embedding vector
  • response.usage.total_tokens reports token usage
  • response.create_time is the server timestamp for the request

Step 4: Same request with cURL

If you want to inspect the raw HTTP request shape directly, send the same operation with cURL:

curl -sS \
-X POST "https://inertialai.com/api/v1/embeddings" \
-H "Authorization: Bearer ${INERTIALAI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "inertial-embed-alpha",
"input": [
{
"text": "The accelerometer measured 9.81 m/s^2 downward acceleration."
}
]
}'

See the full schema in the API reference: Create a new embedding.

Step 5: Common errors and how to fix them

Missing API key (InertialAIError)

If INERTIALAI_API_KEY is not set and you do not pass api_key=... explicitly, the SDK raises InertialAIError when the client is created.

Authentication failure (AuthenticationError / HTTP 401)

Usually means the API key is missing, malformed, invalid, or revoked.

Things to check:

  • Your environment variable is set: echo $INERTIALAI_API_KEY
  • You are using the current API key value from the dashboard
  • Your raw HTTP header, if sending one directly, is exactly Authorization: Bearer <key>

403 Forbidden

Usually means the key is invalid, revoked, expired, or doesn’t have access.

Things to try:

  • Create a new API key in the API Keys section of the InertialAI dashboard.
  • Ensure you’re using the latest copied API key value.

422 Validation Error

The request body didn’t match the schema. With the official SDK, this typically surfaces as ValidationError.

Common causes:

  • Missing required fields like model or input
  • An EmbeddingMultiModalInput object that contains neither text nor time_series
  • Malformed input data when sending raw JSON directly

Fix:

429 Too Many Requests (RateLimitError)

If you receive 429, you’re sending requests too quickly.

Things to try:

  • Let the SDK retry transient failures automatically
  • Reduce concurrency
  • Honor any Retry-After value returned by the API

Support

If you encounter any issues making your first API request, please contact our support team at support@inertialai.com.

Next steps