models/Moondream/Moondream3.1-9B-A2B
M
Moondream

Moondream3.1-9B-A2B

vision
Playground →Compare

Moondream 3 is a fast, efficient 9B mixture-of-experts vision language model (2B active parameters) that delivers frontier-level visual reasoning for tasks like object detection, pointing, OCR, and structured output.

MODALITIES
image
INPUT
$0.500 /1M
OUTPUT
$0 /1M
CONTEXT
4K tok
MAX OUTPUT
4K tok
RELEASED
2026-07-07

Moondream3.1-9B-A2B (moondream/moondream3.1-9B-A2B) is a vision model from Moondream, released 2026-07-07. Context window: 4,096 tokens; max output 4,096. Pricing via AIgateway: input $0.500/M tokens, output $0/M tokens. Capabilities: streaming, vision. Call it via https://api.aigateway.sh/v1/chat/completions with the OpenAI SDK — set model="moondream/moondream3.1-9B-A2B". Best for: OCR, Diagram understanding, Visual Q&A.

model · moondream/moondream3.1-9B-A2B

Use this model

model: moondream/moondream3.1-9B-A2B
curl https://api.aigateway.sh/v1/chat/completions \
  -H "Authorization: Bearer $AIGATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"moondream/moondream3.1-9B-A2B","messages":[{"role":"user","content":"hello"}],"stream":true}'

Capabilities

StreamingVision
CONTEXT
4,096 tok
MAX OUTPUT
4,096 tok

Strengths

  • Image understanding
  • Multimodal reasoning

Use cases

OCRDiagram understandingVisual Q&A

Pricing

Input$0.500 / 1M tokens
Output$0 / 1M tokens
You pay pass-through pricing.
Try in playground →CompareAPI referenceSee usage ranking →

Collections

More image models →More from MoondreamFrontier models →Free-tier models →
API schema

Call Moondream3.1-9B-A2B from any OpenAI SDK

POST https://api.aigateway.sh/v1/chat/completions·Content-Type: application/json·Auth: Bearer sk-aig-...

Request body

json
{
  "model": "moondream/moondream3.1-9B-A2B",
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user",   "content": "Hello!" }
  ],
  "temperature": 0.7,
  "top_p": 0.95,
  "max_tokens": 1024,
  "stream": false

  // For vision: messages[].content can be an array of
  //   { type: "text", text: "..." }  and
  //   { type: "image_url", image_url: { url: "https://..." } }
}

Response

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1776947082,
  "model": "moondream/moondream3.1-9B-A2B",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 12,
    "total_tokens": 36
  }
}

Streaming (SSE) — set "stream": true

// 1. Role announcement (first chunk):
data: {"choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

// 2. Content chunks (final answer):
data: {"choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}

// Finish chunk:
data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

// Terminator:
data: [DONE]

Quickstart

# pip install aigateway-py openai
# aigateway-py adds sub-accounts, evals, replays, jobs, webhook verify.
# openai SDK covers chat — drop-in per our SDK's own guidance.
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aigateway.sh/v1",
    api_key="sk-aig-...",
)

stream = client.chat.completions.create(
    model="moondream/moondream3.1-9B-A2B",
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)

Errors

401authentication_errorInvalid or missing API key
402insufficient_creditsWallet empty (PAYG only)
404not_foundUnknown model or endpoint
429rate_limit_errorOver per-minute limit — see Retry-After header
500server_errorUpstream provider failed (retryable)
503service_unavailableUpstream saturated (retryable)
Full docs →API reference →OpenAPI spec →llms.txt →

Frequently asked questions

What is Moondream3.1-9B-A2B?
Moondream 3 is a fast, efficient 9B mixture-of-experts vision language model (2B active parameters) that delivers frontier-level visual reasoning for tasks like object detection, pointing, OCR, and structured output. It is a vision model from Moondream, accessible via AIgateway's OpenAI-compatible API at slug moondream/moondream3.1-9B-A2B.
How much does Moondream3.1-9B-A2B cost via AIgateway?
Input costs $0.500 per 1M tokens; output costs $0.000 per 1M tokens, billed pass-through.
What is the context window of Moondream3.1-9B-A2B?
4,096 tokens. Maximum output is 4,096 tokens.
How do I call Moondream3.1-9B-A2B from my code?
Point the OpenAI SDK at https://api.aigateway.sh/v1 with your AIgateway key and set model to "moondream/moondream3.1-9B-A2B". The request and response shapes match OpenAI exactly.
Does Moondream3.1-9B-A2B support streaming, tool calling, vision, and JSON mode?
Streaming — yes. Tool calling — no. Vision — yes. JSON mode — no. Prompt caching — no.
What are the best use cases for Moondream3.1-9B-A2B?
OCR, Diagram understanding, Visual Q&A. Key strengths: Image understanding; Multimodal reasoning.
Can I bring my own Moondream API key (BYOK)?
Yes. Attach a Moondream key in your AIgateway dashboard and this model flips to pass-through — you pay Moondream directly and AIgateway adds no platform fee on those calls.