Compare the APIs
The Translation API and the translation tool both provide text translation, but the translation tool integrates translation into conversational workflows and changes how you specify translation requests and configurations. The table below compares the two approaches.| Aspect | Translation API | Translation tool |
|---|---|---|
| Endpoint | /v1/translation | /v1/chat with the prebuilt translation tool specification |
| Request structure | Pass translation parameters such as text, source_language_code, target_language_code, etc. directly in the request body | Provide the text to translate as part of the conversation messages array and include the translation tool in the tools array. Specify additional settings (such as languages or preferences) in the tool configuration, not as direct request parameters. |
| Response format | Translation in the data field | Answer in choices[0].message.content; structured details in the translation_data field |
| Parameter control | Explicit API parameters for each option | Most translation details (languages, formality, etc.) specified in the prompt or tool configuration rather than as top-level request fields |
Migrate your code
The tabs below show a request using the translation API and the same request using the translation tool.- Before: Translation API
- After: Translation tool
The Translation API accepts text and translation parameters directly in the request body:Response:
Map your parameters
The following table shows how Translation API parameters map to the translation tool:| Translation API | Translation tool |
|---|---|
text | Include in the message content field |
source_language_code | tools[0].function.source_language (optional) |
target_language_code | tools[0].function.target_language (optional) |
formality | tools[0].function.formality |
length_control | tools[0].function.length_control |
mask_profanity | tools[0].function.mask_profanity |
With the translation tool, the
source_language and target_language parameters are optional. If you don’t provide them, the model automatically detects the source language and determines the target language from your message.To specify languages explicitly, include them in your message prompt (for example, “Translate to Spanish”) or use the optional source_language and target_language parameters in the tool configuration.Access translation metadata
The translation tool response includes additional metadata in thetranslation_data field. The metadata includes the source text, source language, and target language: