Convert code between languages
Generate a translation of supplied source code into another language or framework.
{
"title": "Convert code between languages",
"description": "",
"method": "POST",
"baseUrl": "https://app.docuwriter.ai",
"endpoint": "/api/generate-language-conversion",
"headers": [
{
"key": "Authorization",
"value": "Bearer YOUR_API_TOKEN",
"type": "string",
"required": true
},
{
"key": "Accept",
"value": "application/json",
"type": "string",
"required": true
},
{
"key": "Content-Type",
"value": "application/json",
"type": "string",
"required": true
}
],
"queryParams": [],
"pathParams": [],
"bodyType": "json",
"requestBody": "{\n \"source_code\": \"def add(a, b):\\n return a + b\",\n \"filename\": \"add.py\",\n \"from_language\": \"Python\",\n \"to_language\": \"JavaScript\"\n}",
"formData": [],
"rawBody": "",
"responses": {
"200": {
"description": "HTTP 200: success: true; data.generation contains generated text; data.generation_id is the numeric saved ID; data.version_number and data.definitive_version_number identify version metadata. Additional response fields are content, converted_code, from_language, to_language under data. The text can include explanation; validate behavior, dependencies and security in the destination project. Illustrative JSON example; sample values are fictional. Some optional or additional resource fields may be omitted.",
"body": "{\n \"success\": true,\n \"data\": {\n \"generation\": \"def add(a, b):\\n return a + b\",\n \"generation_id\": 456,\n \"version_number\": 1,\n \"definitive_version_number\": 1,\n \"content\": \"def add(a, b):\\n return a + b\",\n \"converted_code\": \"def add(a, b):\\n return a + b\",\n \"from_language\": \"JavaScript\",\n \"to_language\": \"Python\"\n }\n}"
},
"401": {
"description": "Missing or invalid account API token.Missing or invalid account API token. Example JSON response.",
"body": "{\n \"message\": \"Unauthenticated.\"\n}"
},
"400": {
"description": "Example: supplied code exceeds the processing budget.",
"body": "{\n \"success\": false,\n \"message\": \"The provided code is too large for processing. Please reduce the amount of code and try again.\"\n}"
}
}
}
Request fields
| Field | Requirement |
|---|---|
source_code |
Required source_code: source-code string. |
filename |
Required filename: filename string. |
name |
Optional name: saved generation title, maximum 255 characters. |
from_language |
Required from_language and to_language: strings up to 100 characters each. |
additional_instructions |
Optional additional_instructions: string. |
Usage notes
- Generation is synchronous and may take time.
- The account must satisfy the generator’s current plan/credit checks (403 if denied).
- Invalid fields return 422; code exceeding the processing token budget returns 400; upstream or output failures can return 500.
- There is no idempotency-key contract: inspect generation history after an uncertain timeout before retrying. Errors and retries.
Updated