---
name: neosantara
description: Use when building AI applications that need unified access to 100+ models (OpenAI, Anthropic, Gemini, DeepSeek, etc.), integrating with coding agents and IDEs, implementing tool calling and structured outputs, or deploying autonomous agents with MCP support. Agents should reach for this skill when working with multi-provider LLM routing, agent orchestration, or building applications that require streaming, vision, embeddings, or batch processing.
metadata:
    mintlify-proj: neosantara
    version: "1.0"
---

# Neosantara Skill

## Product Summary

Neosantara is Indonesia's unified AI Gateway routing requests to 100+ foundation models (OpenAI, Anthropic, Bedrock, Gemini, Mistral, DeepSeek, and others) through a single interface with native Rupiah (IDR) billing. The gateway provides OpenAI and Anthropic SDK compatibility, Model Context Protocol (MCP) support for tool integration, and specialized endpoints for chat, embeddings, image generation, video, audio, and OCR. Key endpoints: `/v1/chat/completions` (OpenAI-compatible), `/anthropic/v1/messages` (Anthropic-compatible), `/v1/responses` (async jobs), `/v1/batches` (bulk processing). Authenticate with API keys prefixed `nsk_` (standard) or `nsk_mcp_` (MCP). Primary docs: https://docs.neosantara.xyz

## When to Use

Reach for this skill when:
- Building chat applications, agents, or LLM-powered backends that need multi-provider model access
- Integrating with coding IDEs (Cursor, Claude Code, Cline, VS Code) or Claude Desktop
- Implementing tool calling, function execution, or structured JSON outputs
- Processing images, generating images, transcribing audio, or extracting text via OCR
- Running batch jobs or asynchronous long-running tasks without RPM limits
- Connecting to remote MCP servers for database, API, or third-party tool access
- Deploying autonomous agents (OpenClaw, Hermes) or cloud-hosted bots
- Needing streaming responses, vision capabilities, or reasoning models
- Working with frameworks like LangChain, CrewAI, LiteLLM, Agno, or Pydantic AI

## Quick Reference

### Base URLs & Protocols

| Protocol | Base URL | Use Case |
|----------|----------|----------|
| OpenAI-compatible | `https://api.neosantara.xyz/v1` | Chat, embeddings, images, audio |
| Anthropic-compatible | `https://api.neosantara.xyz/anthropic` | Claude models via Anthropic SDK |
| Responses API | `https://api.neosantara.xyz/v1/responses` | Async jobs, long-running tasks |
| MCP Gateway | `https://api.neosantara.xyz/v1/mcp` | IDE and agent tool access |
| Batch Processing | `https://api.neosantara.xyz/v1/batches` | Bulk async requests (50% discount) |

### Authentication Headers

| Endpoint Type | Header | Format |
|---------------|--------|--------|
| OpenAI (`/v1/*`) | `Authorization: Bearer` | `Bearer nsk_<32-char-hex>` |
| Anthropic (`/anthropic/*`) | `x-api-key` | `nsk_<32-char-hex>` |
| Anthropic | `anthropic-version` | `2023-06-01` |
| MCP (`/v1/mcp`) | `Authorization: Bearer` | `Bearer nsk_mcp_<32-char-hex>` |

### Essential Parameters for `/v1/chat/completions`

| Parameter | Type | Required | Notes |
|-----------|------|----------|-------|
| `model` | string | Yes | Model ID (e.g., `deepseek-v4.1-flash`, `gemini-3.8-flash`, `claude-4.5-sonnet`) |
| `messages` | array | Yes | List of `{role, content}` objects |
| `temperature` | number | No | 0.0–2.0; default 1.0 |
| `max_tokens` | integer | No | Max output tokens; auto if omitted |
| `stream` | boolean | No | Enable SSE streaming; default false |
| `tools` | array | No | Function definitions for tool calling |
| `response_format` | object | No | `{type: "json_object"}` or `{type: "json_schema", json_schema: {...}}` |
| `mcp_servers` | array | No | Remote MCP server URLs for tool execution |

### Common Model Selection

| Use Case | Recommended Model | Context | Cost |
|----------|-------------------|---------|------|
| Fast, cost-effective | `gemini-3.8-flash` | 1M tokens | $0.75/$3.75 per 1M |
| Reasoning & complex tasks | `deepseek-v4.1-flash` | 1M tokens | $0.15/$0.60 per 1M |
| Claude ecosystem | `claude-4.5-sonnet` | 200k tokens | $3/$15 per 1M |
| Long documents | `garda-core` (Neosantara) | 1M tokens | Rp 300/Rp 1,500 per 1M |
| Free tier | `muse-spark-1.3-contributor` | 1M tokens | Free |

## Decision Guidance

### When to Use `/v1/chat/completions` vs `/v1/responses`

| Criterion | `/v1/chat/completions` | `/v1/responses` |
|-----------|------------------------|-----------------|
| **Latency** | Low (streaming SSE) | Higher (polling) |
| **Timeout** | ~60 seconds | No timeout; async |
| **Use Case** | Interactive chat, real-time UI | Research, reporting, long tasks |
| **Streaming** | Yes (SSE) | No (polling) |
| **State Persistence** | No | Yes (store=true) |
| **Webhooks** | No | Yes (background=true) |

### When to Use Batch Processing vs Real-Time

| Criterion | Real-Time (`/v1/chat/completions`) | Batch (`/v1/batches`) |
|-----------|-------------------------------------|----------------------|
| **Throughput** | Limited by RPM/ITPM/OTPM | Unlimited (50% discount) |
| **Latency** | Immediate | Hours/days |
| **Cost** | Standard pricing | 50% token discount |
| **Use Case** | Interactive apps, agents | Bulk processing, data pipelines |
| **Retry Logic** | Manual | Automatic |

### When to Use Tool Calling vs Structured Outputs

| Criterion | Tool Calling | Structured Outputs |
|-----------|--------------|-------------------|
| **Purpose** | Invoke external functions/APIs | Constrain response format |
| **Execution** | Model decides when to call | Model generates JSON matching schema |
| **Use Case** | Database queries, API calls | Data extraction, form filling |
| **Schema** | Function parameters | JSON schema with strict validation |

### When to Use MCP Gateway vs MCP Connector

| Criterion | MCP Gateway (Server) | MCP Connector (Client) |
|-----------|---------------------|----------------------|
| **Neosantara Role** | Provides tools to IDEs | Connects models to your servers |
| **Endpoint** | `/v1/mcp` | `/v1/chat/completions` |
| **Auth** | `nsk_mcp_` key | `nsk_` key |
| **Audience** | Cursor, Claude Code, Claude Desktop | Backend apps, autonomous agents |
| **Operation** | IDE invokes Neosantara tools | Gateway invokes your MCP servers |

## Workflow

### 1. Initialize Client & Set API Key

```bash
export NEOSANTARA_API_KEY="nsk_your_api_key_here"
```

For OpenAI SDK:
```python
from openai import OpenAI
client = OpenAI(
    base_url="https://api.neosantara.xyz/v1",
    api_key=os.environ["NEOSANTARA_API_KEY"]
)
```

For Anthropic SDK:
```python
from anthropic import Anthropic
client = Anthropic(
    base_url="https://api.neosantara.xyz/anthropic",
    api_key=os.environ["NEOSANTARA_API_KEY"]
)
```

### 2. Choose Model & Check Capabilities

- List available models: `GET /v1/models` or check the [Model Catalog](https://docs.neosantara.xyz/en/gateway/models)
- Verify model supports required capabilities: Tools, Vision, Reasoning, JSON, Embeddings
- Check context window and token pricing (IDR or USD)
- For long documents (>100k tokens), prefer models with 1M context (e.g., `garda-core`, `deepseek-v4.1-flash`)

### 3. Construct Request & Select Endpoint

**For interactive chat:**
```python
response = client.chat.completions.create(
    model="gemini-3.8-flash",
    messages=[{"role": "user", "content": "Your prompt"}],
    stream=True  # Optional: enable SSE streaming
)
```

**For long-running tasks:**
```python
response = client.responses.create(
    model="deepseek-v4.1-flash",
    input="Your prompt",
    instructions="System prompt",
    store=True  # Save state for continuation
)
```

**For bulk processing:**
```python
batch = client.batches.create(
    input_file_id="file_id",  # JSONL file with requests
    endpoint="/v1/chat/completions",
    completion_window="24h"
)
```

### 4. Add Advanced Features (Optional)

- **Streaming:** Set `stream=True` for SSE token streaming
- **Tool Calling:** Pass `tools=[{type: "function", function: {...}}]`
- **Structured Output:** Set `response_format={type: "json_schema", json_schema: {...}}`
- **Vision:** Include `{type: "image_url", image_url: {url: "..."}}` in messages
- **MCP Servers:** Pass `mcp_servers=[{url: "...", name: "..."}]` for tool execution

### 5. Handle Response & Errors

Check response status and usage:
```python
print(response.choices[0].message.content)
print(f"Tokens: {response.usage.prompt_tokens} input, {response.usage.completion_tokens} output")
```

For errors, inspect HTTP status:
- `400`: Invalid parameters (check schema, model name, token limits)
- `401`: Invalid/expired API key
- `402`: Insufficient PAYG balance
- `429`: Rate limit exceeded (RPM, ITPM, or OTPM)
- `503`: Upstream provider error

### 6. Verify & Monitor

- Check token usage in response `usage` object
- Monitor rate limits: Free tier 10 RPM, Basic 20 RPM, Standard 40 RPM, Pro 120 RPM
- For batch jobs, poll `/v1/batches/{batch_id}` until status is `completed`
- Enable request tracing with `x-request-id` header for debugging

## Common Gotchas

- **Missing `anthropic-version` header:** Anthropic SDK requires `anthropic-version: 2023-06-01` on `/anthropic/*` endpoints. Omitting it causes 400 errors.
- **Model not found (404):** Verify model ID matches catalog exactly (case-sensitive). Use `/v1/models` to list available models.
- **Context length exceeded:** Check model's context window in catalog. For large documents, use `garda-core` (1M) or batch processing.
- **Tool calling not working:** Ensure model supports tools (check Capabilities column in catalog). Not all models support tool calling.
- **Structured outputs failing:** Only specific models support `json_schema` (e.g., `deepseek-v4.1-flash`, `gemini-3.8-flash`). Use `json_object` as fallback.
- **Rate limit (429) on free tier:** Free tier has 10 RPM limit. Upgrade tier or use batch processing for bulk workloads.
- **Streaming timeout:** `/v1/chat/completions` has ~60-second timeout. For longer tasks, use `/v1/responses` with `background=true`.
- **MCP key vs standard key:** `nsk_mcp_` keys only work on `/v1/mcp` endpoint. Standard `nsk_` keys work on `/v1/*` and `/anthropic/*`.
- **Image size limit:** Max 20 MB per image. Compress or resize before sending.
- **Batch JSONL format:** Each line must be valid JSON with `custom_id`, `params` (request body). Invalid JSONL causes batch to fail.

## Verification Checklist

Before submitting work:

- [ ] API key is set and valid (test with `/v1/models` list)
- [ ] Model ID exists in catalog and supports required capabilities (Tools, Vision, JSON, etc.)
- [ ] Request headers match protocol: `Authorization: Bearer` for OpenAI, `x-api-key` + `anthropic-version` for Anthropic
- [ ] Message format is correct: `{role: "user|assistant|system", content: "..."}`
- [ ] For tool calling: `tools` array is present and function schema is valid
- [ ] For structured outputs: `response_format` type matches model support (`json_schema` vs `json_object`)
- [ ] For vision: Image URLs are publicly accessible HTTPS or valid Base64 data URIs
- [ ] For streaming: `stream=true` is set and client handles SSE chunks
- [ ] For async: Using `/v1/responses` with `background=true` or `/v1/batches` for long tasks
- [ ] Error handling covers 400, 401, 402, 429, 503 status codes
- [ ] Token usage is logged from response `usage` object
- [ ] Rate limits are respected (check tier RPM/ITPM/OTPM)
- [ ] MCP servers (if used) are reachable and return valid tool definitions

## Resources

- **Comprehensive Navigation:** [https://docs.neosantara.xyz/llms.txt](https://docs.neosantara.xyz/llms.txt) — Full page-by-page index for agent navigation
- **Gateway Overview & Endpoints:** [https://docs.neosantara.xyz/en/gateway/overview](https://docs.neosantara.xyz/en/gateway/overview)
- **Model Catalog & Pricing:** [https://docs.neosantara.xyz/en/gateway/models](https://docs.neosantara.xyz/en/gateway/models)
- **API Reference & OpenAPI:** [https://docs.neosantara.xyz/en/api-reference/introduction](https://docs.neosantara.xyz/en/api-reference/introduction)

---

> For additional documentation and navigation, see: https://docs.neosantara.xyz/llms.txt