API Reference
Higain.ai REST API
OpenAI-compatible API hosted in Nepal. Drop into any existing integration by changing only the base URL and API key.
Authentication
Get your API key and authenticate requests.
Chat Completions
Send messages and receive AI responses.
Agents API
Create and orchestrate autonomous agents.
Streaming
Stream responses token by token in real-time.
Base URL & Authentication
Base URL
https://api.higain.ai/v1
Authorization header
Authorization: Bearer hgn-sk-...
Every request must include your API key as a Bearer token. Manage keys in your dashboard.
Chat Completions
POST/v1/chat/completions
# Python
import higain
response = higain.chat.completions.create(
model="llama-3.1-70b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Namaste! Help me write a Python function."}
]
)
print(response.choices[0].message.content)
# TypeScript
import Higain from 'higain';
const client = new Higain();
const msg = await client.chat.completions.create({
model: 'llama-3.1-70b',
messages: [{ role: 'user', content: 'Hello!' }],
});
Streaming
Add stream=True to receive server-sent events as tokens are generated. Ideal for chat UIs where you want to show output as it arrives.
stream = higain.chat.completions.create(
model="llama-3.1-70b",
messages=[...],
stream=True
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta: print(delta, end="", flush=True)
Agents API
POST/v1/agents
Create autonomous agents that can use tools, call APIs, run code, and complete multi-step tasks.
agent = higain.agents.create(
model="llama-3.1-70b",
name="code-reviewer",
instructions="Review code for bugs and security issues.",
tools=["code_interpreter", "web_search"]
)
run = higain.agents.run(agent.id, input="Review this PR: ...")
Embeddings
POST/v1/embeddings
Convert text to dense vector representations. Use for semantic search, RAG pipelines, and clustering.
embedding = higain.embeddings.create(
model="higain-embed-v1",
input="Nepal is a landlocked country in South Asia."
)
print(embedding.data[0].embedding) # 1536-dim vector
Endpoints
POST
/v1/chat/completions
Create a chat completion
GET
/v1/models
List available models
POST
/v1/agents
Create a new agent
POST
/v1/agents/{id}/run
Run an agent task
GET
/v1/agents/{id}
Get agent status & output
POST
/v1/embeddings
Create text embeddings