# Models reference

GraphN routes each agent to a **language model** you choose in the agent editor. Built-in models are ready to use; you can also **import** an OpenAI-compatible endpoint (for example vLLM, Ollama with the OpenAI API, or a third-party API) and select it like any other model.

## Built-in models

When you open the **Models** page (under **Resources** in the sidebar), you see a card grid of every model available in your workspace, including the OCR, embedding, and reranker models. When configuring an **Agent** node on the workflow canvas, you pick a model from a dropdown in the node panel, which lists only **chat** and **vision** models.

### Chat and multimodal models

The following models are callable through the model API. All of them except Gemma 4 E4B are in the agent model picker. Each links to its catalog page with the full editorial write-up, specifications, and runnable API examples.

| Model                                                          | Callable name         | Type          | Context | When to use                                                                        |
| -------------------------------------------------------------- | --------------------- | ------------- | ------- | ---------------------------------------------------------------------------------- |
| [Qwen3 80B Instruct](/inference/qwen3-80b)                     | `qwen3-80b`           | Chat          | 128K    | Everyday chat and agent work at near-flagship quality; the default chat model.     |
| [gpt-oss 120B](/inference/gpt-oss-120b)                        | `gpt-oss-120b`        | Chat          | 128K    | Reasoning with a cost dial: low, medium, or high effort per request.               |
| [Qwen3.8 27B (image+video)](/inference/qwen3.8-27b)            | `qwen3.8-27b`         | Chat / Vision | 256K    | Coding, long-horizon agents, and image/video understanding in one dense model.     |
| [Qwen3.5 9B Vision (image+video)](/inference/qwen3-vl)         | `qwen3-vl`            | Vision        | 256K    | The most economical way to put images and video in front of a model.               |
| [Gemma 4 E4B (text+image+video+audio)](/inference/gemma-4-e4b) | `gemma-4-e4b`         | Audio chat    | 64K     | Speech and images in one conversational model, without a separate ASR step.        |
| [GLM-5.3](/inference/glm-5.3)                                  | `glm-5.3`             | Chat          | 1M      | Complex coding and long-horizon agentic work; reasons before answering.            |
| [DeepSeek V4.1 Flash](/inference/deepseek-v4.1-flash)          | `deepseek-v4.1-flash` | Chat / Vision | 1M      | Long-context reasoning and coding over large codebases, with image input.          |
| [Inkling 2 Small](/inference/inkling-2-small)                  | `inkling-2-small`     | Chat / Vision | 128K    | Agents, coding assistants, and chat over text and images.                          |
| [Kimi K2.5 (image)](/inference/kimi-k2.5)                      | `kimi-k2.5`           | Chat / Vision | 256K    | Frontier-scale agentic work with images: code from visual specs, sub-agent splits. |
| [Qwen3 VL 235B Instruct (image)](/inference/qwen3-vl-235b)     | `qwen3-vl-235b`       | Chat / Vision | 256K    | Demanding image understanding, OCR and GUI agents; image input only.               |
| [Mistral Large 3](/inference/mistral-large-3)                  | `mistral-large-3`     | Chat / Vision | 256K    | Long-context assistants, retrieval and enterprise agents, with image input.        |

> **Note:** The agent model selector offers **chat** and **vision** models. Gemma 4 E4B is an audio chat model, so it is not in the selector; use it from the Playground or the model API.

![Model picker showing available chat and vision models as a card grid](/docs/screenshot-model-picker.png)

### OCR and retrieval models (not in the agent model picker)

The platform registers **OCR**, **embedding**, and **reranker** models for features such as document reading and retrieval. They are **not** offered as the main LLM in the agent model selector.

| Model                                                                       | Model ID             | Type      | When to use                                                                                         |
| --------------------------------------------------------------------------- | -------------------- | --------- | --------------------------------------------------------------------------------------------------- |
| [DeepSeek OCR](/inference/deepseek-ocr)                                     | `deepseek-ocr`       | OCR       | Turns document images into markdown with layout preserved.                                          |
| [BGE-M3 Embeddings (1024 dim)](/inference/bge-m3)                           | `bge-m3`             | Embedding | Semantic search and retrieval across knowledge bases (**default** text embedding).                  |
| [Qwen3-VL Embeddings (4096 dim, multimodal)](/inference/qwen3-vl-embedding) | `qwen3-vl-embedding` | Embedding | Multimodal knowledge bases that index **text and images** together; selectable at KB creation time. |
| [BGE Reranker v2](/inference/bge-reranker)                                  | `bge-reranker`       | Reranker  | Reranking search hits for better relevance ordering.                                                |
| [Qwen3-VL Reranker (multimodal)](/inference/qwen3-vl-reranker)              | `qwen3-vl-reranker`  | Reranker  | Relevance scoring across modalities: text against images and back.                                  |

### Decision guide

| Your goal                                         | Recommended model                                     |
| ------------------------------------------------- | ----------------------------------------------------- |
| General agents, tools, structured JSON            | **Qwen3 80B Instruct**                                |
| Long inputs or long-horizon agents (256K context) | **Qwen3.8 27B**                                       |
| Code-heavy agents and IDE-style workflows         | **Qwen3.8 27B**                                       |
| Adjustable reasoning effort per request           | **gpt-oss 120B**                                      |
| Multimodal inputs (images, video + text)          | **Qwen3.5 9B Vision** or **Qwen3.8 27B**              |
| Reading scanned documents into markdown           | **DeepSeek OCR** (through document conversion)        |
| Voice input without a separate transcription step | **Gemma 4 E4B** (Playground or model API)             |
| Fine-tuned or external API you control            | Import an endpoint (next section) and pick that model |

---

## Custom model import

Import an **OpenAI-compatible** HTTP API whose chat path is **`/v1/chat/completions`** (same [request shape as OpenAI](https://platform.openai.com/docs/api-reference/chat)). Typical sources include **[vLLM](https://docs.vllm.ai/)**, **[Ollama](https://ollama.com/)** (OpenAI compatibility mode), **[OpenAI](https://platform.openai.com/)**, **Google Gemini via OpenAI compatibility**, and **[OpenRouter](https://openrouter.ai/)**.

> **Tip:** Want to import directly from HuggingFace or your own S3 bucket from a script instead of the wizard below? See the [Python SDK tutorial](./tutorial-custom-model-sdk.md) for an end-to-end walk-through.

### Import from the UI

1. In the sidebar, under **Resources**, click **Models**.
2. Click **Import Model** (top-right corner).
3. The import wizard has two tabs:

**API Endpoint** (connect to a running inference server):

1. Choose a provider:
   - **OpenAI**, **Google (Gemini)**, or **OpenRouter** — preset base URLs; you attach a **secret** that stores your API key, then use **Fetch Available Models** to list models from **`/v1/models`** (filtered to chat-relevant entries).
   - **Custom Provider** — for any other OpenAI-compatible base URL (for example `http://your-host:8000/v1` for a local vLLM server). Enter the **endpoint URL**, **model id** (exactly as the server expects in API calls), and optionally an **API key secret** if the server requires authentication.
2. (Optional) Click **Configure** to set **type** (chat, vision, or embedding), **capabilities** (for example tool calling, vision, streaming, json mode), **context length**, and **description**.
3. Click **Import**. You are taken to the new model’s detail page.

> **Tip:** For self-hosted vLLM or Ollama, the base URL usually ends with **`/v1`**. The model id must match what you pass when calling that server (for example the served model name).

**HuggingFace Weights** (deploy a model from HuggingFace):

1. Enter the full **[HuggingFace](https://huggingface.co/) model ID** (for example `meta-llama/Llama-3-8B-Instruct`).
2. Optionally set a **display name** (auto-generated from the model ID if left blank).
3. If the model is gated or private, click **Attach secret** to provide your HuggingFace token.
4. Click **Validate & Continue** to proceed through the optimization and scaling steps.

![Import Model wizard showing API Endpoint and HuggingFace Weights tabs](/docs/screenshot-model-import.png)

### Test the connection before using an agent

After import, open the imported model’s page. In the **Test Model** section, enter a short prompt and run the test. The app streams a reply so you can confirm the endpoint, credentials, and model id work together.

> **Warning:** If the test fails, fix the endpoint URL, secret, or model id before selecting this model on an agent. Otherwise runs fail at inference time.

### Troubleshooting

- **`400`** — the endpoint or model id is missing, the endpoint is not allowed, or the API key secret cannot be resolved. Re-check the secret, then test again.
- **`502` with "upstream returned status 401" or "upstream returned status 403"** — the provider rejected the API key. Replace or reattach the secret.
- **`502` with "upstream returned status 404"** — the **model id** is not the name the endpoint serves. Use **Fetch Available Models**, or call the provider's `/v1/models` endpoint directly.
- **`502` with "connection test failed" or "invalid response from upstream"** — the endpoint is unreachable, is not an OpenAI-compatible chat server, or the base URL is missing `/v1`.

### Verify connectivity with the API (optional)

You can send a single chat completion **through GraphN** to validate an endpoint **before** or **after** saving an imported model, using the same workspace and auth as the app.

Replace the placeholders with your workspace id, bearer token, base URL (must include `/v1`), and upstream model id:

```bash
curl -X POST "https://cp.graphn.ai/v1/${WORKSPACE_ID}/imported-models/test-connection" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "endpoint": "https://your-endpoint.example.com/v1",
    "model_id": "your-model-name",
    "api_key_secret_id": null,
    "message": "Reply with one short sentence."
  }'
```

Omit `api_key_secret_id` or set it to `null` when the server does not use a bearer token. When you store a key in **Secrets**, pass that secret’s id so the test can authenticate.

A successful response includes a **response** field with the generated text, the **model** name returned by the server, and **usage** token counts when the upstream returns them.

### Register an imported model with the API

To create the imported model record programmatically (equivalent to finishing the import wizard):

```bash
curl -X POST "https://cp.graphn.ai/v1/${WORKSPACE_ID}/imported-models" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "name": "my-endpoint-model",
    "display_name": "My vLLM Model",
    "endpoint": "https://your-endpoint.example.com/v1",
    "model_id": "your-model-name",
    "api_key_secret_id": null,
    "type": "chat",
    "capabilities": ["tool_calling"],
    "context_length": 128000,
    "description": "Imported from a vLLM cluster."
  }'
```

Use a unique **`name`** (URL-friendly identifier) within the workspace; agents reference this value as the **model** setting. **`display_name`** is what people see in lists and selectors. A successful create returns `201` with the imported-model object, including its `id`. List imports with `GET /v1/{workspace_id}/imported-models`.

### List models from a provider endpoint (API)

To mirror **Fetch Available Models** in the UI (OpenAI-style **`GET /v1/models`** on the same base URL as chat):

```bash
curl -X POST "https://cp.graphn.ai/v1/${WORKSPACE_ID}/imported-models/discover-models" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "endpoint": "https://api.openai.com/v1",
    "api_key_secret_id": "YOUR_SECRET_ID"
  }'
```

`endpoint` and `api_key_secret_id` are required; the secret must hold the provider API key.

---

## See also

- [Function SDK Reference](./sdk-reference.md) — use models in custom Python functions with `chat.complete(model="...")` and `vision.analyze(model="...")`
- [Concepts](./concepts.md) — how models relate to agents and workflows
- [API Reference](./api-reference.md) — full endpoint reference including imported model CRUD
