Ashna AI Agent Platform API

Build powerful AI agents on top of multiple language models. Access GPT, Gemini, and custom models through a unified API. Create, configure, and deploy AI agents in minutes.

Base URL

https://api.ashna.ai/v1/api

Platform Overview

Ashna AI provides an agent-based architecture that allows you to:

  • Select from multiple AI models (GPT-4, GPT-3.5, Gemini Pro, Gemini Flash)
  • Create custom agents with specific instructions and behaviors
  • Attach tools and capabilities to agents for specialized tasks
  • Configure memory and context management for conversations
  • Stream responses in real-time for better UX

Quickstart

Get started with the Ashna AI API in under 5 minutes.

1. Get Your API Key

Sign up at app.ashna.ai/api-dashboard/overview and generate your API key from the dashboard.

2. Make Your First Request

cURL
curl https://api.ashna.ai/v1/api/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "agent_abc123",
"message": "Hello, can you help me?"
}'

Authentication

All API requests require authentication using an API key passed in the Authorization header.

Headers

Authorizationstring

Bearer token with your API key. Format: Bearer YOUR_API_KEY

Content-Typestring

Should be set to application/json

Example Request
curl https://api.ashna.ai/v1/api/chat \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json"

Errors

The API uses standard HTTP response codes. Error responses include a JSON body with details.

400
Bad Request

Invalid request parameters or malformed JSON

401
Unauthorized

Missing or invalid API key

404
Not Found

Resource does not exist

429
Rate Limit Exceeded

Too many requests in a given time period

500
Internal Server Error

Something went wrong on our end

Error Response Format

JSON
{
"error": {
"type": "invalid_request",
"message": "Agent ID is required",
"code": "missing_parameter"
}
}

Webhooks & Events

COMING SOON

Configure webhooks to receive real-time notifications when events occur in your agents.

Supported Events

  • agent.created - New agent created
  • agent.execution.started - Agent execution began
  • agent.execution.completed - Agent execution finished
  • tool.invoked - Tool was called by agent
Webhook Payload Example
{
"event": "agent.execution.completed",
"timestamp": "2026-01-04T10: 30: 00Z",
"data": {
"agent_id": "agent_abc123",
"execution_id": "exec_xyz789",
"status": "success",
"duration_ms": 1450
}
}

API Endpoints

Ashna AI provides multiple endpoints for different use cases, from high-level chat interfaces to low-level completion APIs.

Chat API

The high-level, stateful chat endpoint designed for UI-based conversations. This endpoint manages conversation state, injects bot configurations, and handles streaming responses.

Endpoint

POST/v1/api/chat

Key Parameters

chatIdstring

Unique identifier for the conversation. Used to maintain state across multiple messages.

messagesUIMessage[]

Array of UIMessage objects representing the conversation history.

modelstring

Model identifier (e.g., "ashnaai", "gemini-pro").

streamboolean

Enable streaming responses for real-time output.

streamTypetext | data

Stream format: "text" for simple text streaming, "data" for structured event streaming.

temperaturenumber

Controls randomness (0.0-2.0). Lower values are more deterministic.

maxTokensnumber

Maximum number of tokens to generate in the response.

Request Example

cURL
curl https://api.ashna.ai/v1/api/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "chat_abc123",
"messages": [
{
"id": "msg_1",
"role": "user",
"parts": [
{
"type": "text",
"text": "What is machine learning?"
}
]
}
],
"model": "ashnaai",
"temperature": 0.7,
"maxTokens": 500,
"stream": true,
"streamType": "data"
}'

Response Example

JSON
{
"id": "msg_2",
"role": "assistant",
"parts": [
{
"type": "text",
"text": "Machine learning is a subset of artificial intelligence..."
}
],
"metadata": {
"model": "ashnaai",
"tokensUsed": 245,
"finishReason": "stop"
}
}

Chat Completions

OpenAI-compatible, stateless chat completion endpoint. Ideal for developers and SDK usage with role-based messages.

Endpoint

POST/v1/api/chat/completions

Key Parameters

messagesarray

Array of message objects with "role" (system, user, assistant) and "content".

modelstring

Model identifier (e.g., "ashnaai", "gemini-pro").

temperaturenumber

Sampling temperature between 0 and 2.

Request Example

cURL
curl https://api.ashna.ai/v1/api/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ashnaai",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Explain quantum computing"
}
],
"temperature": 0.7,
"max_tokens": 500
}'

Response Example

JSON
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1704369000,
"model": "ashnaai",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Quantum computing leverages quantum mechanics..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 245,
"total_tokens": 270
}
}

Text Completions

Legacy single-prompt text completion endpoint. Included for backward compatibility with simple one-shot text generation use cases.

Endpoint

POST/v1/api/completions

Key Parameters

promptstring

The text prompt to generate completion for.

modelstring

Model identifier (e.g., "ashnaai").

Request Example

cURL
curl https://api.ashna.ai/v1/api/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ashnaai",
"prompt": "Explain quantum computing in simple terms",
"max_tokens": 500,
"temperature": 0.7
}'

Response Example

JSON
{
"id": "cmpl-abc123",
"object": "text_completion",
"created": 1704369000,
"model": "ashnaai",
"choices": [
{
"text": "Quantum computing is a revolutionary approach...",
"index": 0,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 245,
"total_tokens": 257
}
}

Streaming Responses

Stream responses in real-time for better user experience.

cURL
curl https://api.ashna.ai/v1/api/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Write a story about AI",
"stream": true
}'

Stream Event Format

Server-Sent Events
data: {"type": "content", "delta": "Once upon"}
data: {"type": "content", "delta": " a time"}
data: {"type": "content", "delta": " there was"}
data: {"type": "done", "execution_id": "exec_123"}

SDKs & Integrations

Official SDKs and integrations for popular platforms.

Py

Python SDK

from openai import OpenAI
# Simply change the base URL
client= OpenAI(
api_key="YOUR_ASHNA_API_KEY",
base_url="https://api.ashna.ai/v1/api"
)
# Use standard OpenAI code
response= client.chat.completions.create(
model="ashnaai",
messages=[
{"role": "user", "content": "Hello!"}
]
)
JS

JavaScript/TypeScript SDK

import OpenAI from 'openai';
// Simply change the base URL
const client = new OpenAI({
apiKey: 'YOUR_ASHNA_API_KEY',
baseURL: 'https://api.ashna.ai/v1/api'//api.ashna.ai/v1/api'
});
// Use standard OpenAI code
const response = await client.chat.completions.create({
model: 'ashnaai',
messages: [
{ role: 'user', content: 'Hello!' }
]
});