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:
- An InertialAI account: Creating an Account
- An API key: Authentication
- Python 3.11 or newer if you want to use the official SDK
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.datacontains oneEmbeddingDataobject per input itemresponse.data[0].embeddingis the embedding vectorresponse.usage.total_tokensreports token usageresponse.create_timeis 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
modelorinput - An
EmbeddingMultiModalInputobject that contains neithertextnortime_series - Malformed
inputdata when sending raw JSON directly
Fix:
- Compare your request body to the schema defined in Create a new embedding
- Use
EmbeddingMultiModalInputinstead of manually building JSON in Python
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-Aftervalue 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
- Learn the official Python client: Official Python SDK
- Go deeper on async, timeouts, and errors: Async, Configuration, and Errors
- Learn all the ways to use embeddings: Using the Embeddings Endpoint
- See OpenAI compatibility guidance: OpenAI Python SDK Compatibility
- Explore endpoints and schemas: InertialAI API