---
title: "Code translator"
method: POST
path: "/api/v1/ai/code-translate"
tags: ["ai"]
---

# Code translator

`POST /api/v1/ai/code-translate`

## Request

- Base URL: `https://toolforte.com`
- URL: `https://toolforte.com/api/v1/ai/code-translate`
- Auth: one of:
  - HTTP bearer
  - none

Translate a piece of code from one programming language to another (for example Python to TypeScript, JavaScript to Go, VBA to Python, jQuery to plain JavaScript, SQL between dialects). Keeps the behaviour, uses the idioms of the target language, and lists what could not be translated one to one: libraries without an equivalent, integer sizes, error handling, concurrency. Meant for snippets and single files up to about 10,000 characters, not whole projects. Costs 10 credits per call with an API key or a signed-in session, drawn from the same monthly balance as REST calls (1 credit) and renders (25). Without either, a small free demo allowance per day. Also available on the MCP server as translate_code.

## Request body

- object
  - `code` string, required: The source code.
  - `from` string: Source language. Detected when left out.
  - `to` string, required: Target language, for example TypeScript, Python 3, Go, Rust, C#, Kotlin, PHP 8.
  - `notes` string: Optional wishes: a framework, a style, a runtime version.

## Response `200`

The tool's answer plus metering

- object
  - `ok` boolean
  - `data` object
    - `code` string, required
    - `sourceLanguage` string, required
    - `targetLanguage` string, required
    - `notes` string[], required
    - `caveats` string[], required

## Other responses

- `400`: Missing or invalid request fields
- `429`: Daily demo allowance or monthly credits used up
- `502`: The model did not return a usable answer
- `503`: AI temporarily unavailable

---

[API](https://skmtc.dev/toolforte/apis/toolforte-api.md) · [All operations](https://skmtc.dev/toolforte/apis/toolforte-api/llms.txt) · [OpenAPI document](https://skmtc.dev/toolforte/apis/toolforte-api/revisions/4d814d484dfc?raw)
