Source: https://ailoot.ai/models/en/voyageai-voyage-code-4/
Canonical: https://ailoot.ai/models/en/voyageai-voyage-code-4/
Language: en

# VoyageAI by MongoDB: voyage-code-4

[Markdown](https://ailoot.ai/models/en/voyageai-voyage-code-4/index.md) · [JSON](https://ailoot.ai/models/en/voyageai-voyage-code-4/facts.json)

## [VoyageAI by MongoDB: voyage-code-4](https://ailoot.ai/models/en/voyageai-voyage-code-4/)

Voyage AI voyage-code-4 is a code embedding model for finding relevant source from questions, issue descriptions and coding-agent goals. It supports 32,000-token inputs and 256, 512, 1024 or 2048 dimensions, with floating-point and quantized representations.

- [**Ailoot Ultra · Embeddings** `POST /v1/embeddings` `voyageai/voyage-code-4`](https://ailoot.ai/models/en/voyageai-voyage-code-4/#method-0)

About the model

This description covers the model’s capabilities. Available in Ailoot inputs, outputs and options are listed for the selected method below.

voyage-code-4 is Voyage AI’s code-specialised embedding model for repository search and coding-agent retrieval. It is designed to help locate relevant source when the starting point is a question, a symptom or a task description rather than a known identifier. It represents code and textual information as numerical vectors for retrieval; it does not edit the repository or generate a fix.

#### Retrieve code from the issue being investigated

The maker describes a training corpus curated from completed pull requests, connecting natural-language queries with code. This is a meaningful distinction from training examples built mainly around source files and their docstrings: the retrieval task can start with the behavior that needs investigation.

Prepare a query such as “Find where an empty result causes a successful operation to be reported as a failure.” Index readable source sections with their file paths and relevant comments. Keep the function’s surrounding conditions where they explain its behavior. A returned candidate should lead the reader or agent back to the source section it represents.

Semantic retrieval can complement exact identifier and full-text search. If a function name is already known, an exact lookup remains useful. If only a symptom is known, vector search can provide candidates to inspect and refine with another query.

#### Query and document roles

Voyage’s retrieval guidance distinguishes the query from the corpus document through query/document input types. For code search, use the issue or task description as the query and the indexed source or documentation as the document. The published recipe adds role-specific retrieval instructions during embedding.

Keep the code’s original formatting, names and relevant documentation available outside the vector. For a source section, retain its file path and location; for a programming guide, retain its heading. After retrieval, inspect the actual code and its callers before choosing an edit. A candidate’s relevance does not establish that it is the sole cause of a reported problem.

#### Context and representation choices

The exact model’s published context length is 32,000 tokens. Its default embedding has 1024 dimensions, with 256, 512 and 2048 dimensions also supported through Matryoshka learning. The announcement documents 32-bit floating-point, signed and unsigned 8-bit integer, and binary representations.

Select one dimension and representation for the collection, and keep them with its metadata. Floating-point vectors and quantized representations require the corresponding storage and comparison handling. A binary representation encodes vector information differently from a list of ordinary floating-point coordinates; preserve that distinction when preparing results for search.

For a long file, choose coherent sections whose source locations can be recovered. A function may need an adjacent type definition or comment to explain a condition, while a whole oversized file may include unrelated material. Keep the section aligned with the task to be searched rather than treating the maximum context as a preferred chunk size.

#### Use retrieved source as evidence

A practical coding-agent workflow retrieves candidate source, reads those files, follows relevant references and narrows the search as the investigation progresses. The retrieved text becomes context for the reasoning or editing stage. Keep its association with the indexed repository revision so that a candidate is inspected against the correct source.

voyage-code-4’s edition-specific contribution is its focus on the issue-to-code retrieval step used by coding agents, together with flexible dimensions and representations. Its output is a retrieval vector, while diagnosis, editing and validation remain separate tasks grounded in the actual repository.

**Ailoot Ultra · Embeddings** `POST /v1/embeddings` `voyageai/voyage-code-4`

[`voyageai/voyage-code-4`](https://ailoot.ai/models/en/#m=voyageai%2Fvoyage-code-4&route=Ultra&caller=voyageai%2Fvoyage-code-4&fmt=embeddings)

VoyageAI by MongoDB /`voyageai/voyage-code-4`

### Overview

Voyage AI voyage-code-4 is a code embedding model for finding relevant source from questions, issue descriptions and coding-agent goals. It supports 32,000-token inputs and 256, 512, 1024 or 2048 dimensions, with floating-point and quantized representations.

Accepted inputs

Text · token\_ids

Results

embedding

### Available in Ailoot · inputs & methods

**Ailoot Ultra · Embeddings** `POST /v1/embeddings`

Input types

`text`, `token_ids`

Output types

`embedding`

Context

32,000 tokens

Output format

json

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits voyageai/voyage-code-4 | Default— |
| Field`input` | Type`string\|string[]\|integer[]\|integer[][]` | RequirementRequired | Values & limits Minimum items: 1 Conditions: Nonempty homogeneous batch. Token IDs are nonnegative integers. Input budget: Maximum: 32,000 · Text unit: UTF8 bytes · Token unit: token-array elements | Default— |
| Field`encoding_format` | Type`string` | RequirementOptional | Values & limits float | Defaultfloat |
| Field`dimensions` | Type`integer` | RequirementNot supported | Values & limits Minimum: 1 | Default— |
| Field`user` | Type`json_value` | RequirementOptional | Values & limits Conditions: Source allows this JSON metadata field; exact upstream semantics are model-specific. | Default— |
| Field`session_id` | Type`json_value` | RequirementOptional | Values & limits Conditions: Source allows this JSON metadata field; exact upstream semantics are model-specific. | Default— |
| Field`trace` | Type`json_value` | RequirementOptional | Values & limits Conditions: Source allows this JSON metadata field; exact upstream semantics are model-specific. | Default— |
| Field`provider` | Type`object` | RequirementOptional | Values & limits Conditions: provider.options rejected | Default— |

Input material combinations

**text\_to\_embedding**

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`content_type` | Contractapplication/json |
| Parameter`required` | Contractmodel, input |
| Parameter`input_shapes` | Contractstring, string\[\], nonnegative\_integer\_token\_array, nonnegative\_integer\_token\_array\[\] |
| Parameter`encoding_format` | Contractfloat |
| Parameter`dimensions_override` | Contractfalse |
| Parameter`max_input_budget_units` | Contract32000 |
| Parameter`multimodal_objects` | Contractfalse |
| Parameter`material_types` | Contracttext, token\_ids |

Lifecycle: `synchronous_json`

Keep every vector index and dimension.

Multimodal model name does not admit image objects on this exact path.

### Pricing

Tariff references do not add request options. Supported parameters are listed for the selected method.

Fast mode

Standard rate When fast mode is selected

Flex mode

Standard rate When flex mode is selected

Maximum reasoning effort

Standard rate When maximum reasoning effort uses the default adjustment

#### Ailoot rates

#### Prices by configuration

| Configuration | Rate schedule | Charge |
| --- | --- | --- |
| ConfigurationBase token rates | Rate scheduleBase rate | Charge Input · Input tokens **$0.00024** / 1K tokens Output · Output tokens **$0** / 1K tokens Input · Cache read **—** / 1K tokens Input · Cache write **—** / 1K tokens Input · Cache write, 1 hour **—** / 1K tokens |

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot Ultra · Embeddings

curlPython SDK

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "voyageai/voyage-code-4", "input": ["First document", "Second document"]}')

Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/embeddings \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import json
from pathlib import Path
r=json.loads(Path("result.json").read_text())
for x in r.get("data",[]): print(json.dumps({"index":x.get("index"),"embedding":x.get("embedding")}))
PY_RESULT
```

```python
from openai import OpenAI
import os

client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.embeddings.create(model='voyageai/voyage-code-4',input=["First document","Second document"])
print(result)
for item in result.data:print(item.index,item.embedding)
```

### Receive and save results

#### Ailoot Ultra · Embeddings

json

##### Keep all completed results

Keep every complete returned response, file and content part.

Keep every vector with its index. Vector count must equal input count; dimensions must be consistent.

##### If the original response needs checking

No embedding job endpoint is introduced.

Response fields

| Field | Type |
| --- | --- |
| Field`object` | Typestring |
| Field`model` | Typestring |
| Field`data[].index` | Typeinteger |
| Field`data[].embedding` | Typefinite float\[\] |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |

### Aliases

#### Model aliases

**Ailoot Ultra** [`voyageai/voyage-code-4`](https://ailoot.ai/models/en/#m=voyageai%2Fvoyage-code-4&route=Ultra&caller=voyageai%2Fvoyage-code-4&fmt=embeddings)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`voyageai/voyage-code-4`](https://ailoot.ai/models/en/#m=voyageai%2Fvoyage-code-4&route=Ultra&caller=voyageai%2Fvoyage-code-4&fmt=embeddings)

FAQ · VoyageAI by MongoDB: voyage-code-4

What inputs and results are available?

`POST /v1/embeddings` · `voyageai/voyage-code-4`: `text`, `token_ids` → `embedding`

Which fields does the request use?

`POST /v1/embeddings` · `voyageai/voyage-code-4`: `model`, `input`, `encoding_format`, `provider`

What limits apply?

`POST /v1/embeddings` · `voyageai/voyage-code-4`: `ctx`: `32000`; `input.budget.maximum`: `32000` (UTF8 bytes); `input.min_items`: `1`

Connect Ailoot to Claude Code, OpenCode, Hermes or your own app.

## The company and its project portfolio

The company and its project portfolio: millions of customers; monthly sales in the billions.

## Buy tokens at a discount.

Subscription discounts for regular use. Promo codes offer up to 50% off token purchases.

Subscription

Choose a discounted plan for your regular requests.

Promo code: up to 50% off

Enter your code at checkout. The price updates to reflect the current promotion.

Spending in your history

The model, tokens and amount are recorded for each request.

[Choose a subscription](https://ailoot.ai/docs/en/billing/subscriptions/) · [View model prices](https://ailoot.ai/models/en/)

## Connect the API to a product you sell.

Use Ailoot in SaaS, apps and bots under its official service offer and licence agreement. Request a reseller licence for resale.

Commercial application

Add text, image, video and audio generation to paid features in your service.

Reseller licence

Send a description of your project and how you provide access. Request written terms for use and resale.

Documents on the website

The service offer, licence agreement and data processing policy are available before you connect.

[Request a reseller licence](mailto:support@ailoot.ai) · [Service offer and licence agreement](https://ailoot.ai/legal/offer?lang=en)

## Ailoot · The company and its project portfolio





Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.





The company and its project portfolio: millions of customers; monthly sales in the billions.





Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
