Translation Quickstart
This guide makes your first translation against Shisa Translation. You will need an API key — create one in the Shisa platform. New accounts include $10 in free credits.
1. Get your API key
Sign up for a Shisa AI account and obtain your API key from the Shisa platform. Include it in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Translation authenticates with a standard bearer token — Authorization: Bearer YOUR_API_KEY. Shisa API keys start with shsk:; pass the full key. A missing or malformed token returns a 401 error. See Authentication for the full conventions.
Keep your API key out of source control. Read it from an environment variable (for example SHISA_API_KEY) in real applications.
2. Make a request
The request is multipart/form-data — send the text, source_lang, and target_lang as form fields. Set stream to "false" for a single JSON response.
curl
curl -X POST "https://api.shisa.ai/translate/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "text=今日は素晴らしい天気ですね。" \
-F "source_lang=ja" \
-F "target_lang=en" \
-F "stream=false"
Python
import requests
def translate_text(text, source_lang="ja", target_lang="en"):
response = requests.post(
"https://api.shisa.ai/translate/",
headers={
"Authorization": "Bearer YOUR_API_KEY"
},
data={
"text": text,
"source_lang": source_lang,
"target_lang": target_lang,
"stream": "false"
}
)
return response.json()
# Example usage
result = translate_text("ビジネスの成功をお祈りします。")
print(result["choices"][0]["message"]["content"])
JavaScript
const translateText = async (text, sourceLang = 'ja', targetLang = 'en') => {
const formData = new FormData();
formData.append('text', text);
formData.append('source_lang', sourceLang);
formData.append('target_lang', targetLang);
formData.append('stream', 'false');
const response = await fetch('https://api.shisa.ai/translate/', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
},
body: formData,
});
const data = await response.json();
return data.choices[0].message.content;
};
// Example usage
const translation = await translateText('日本とアメリカの架け橋になる');
console.log(translation); // Returns translated text
3. Read the response
The API returns an OpenAI-style JSON response. The translated text is at choices[0].message.content:
{
"id": "trans_20f537a6-da14-4c98-8ee3-063319c45072",
"object": "translation.completion",
"created": 1768299459,
"model": "shisa-ai/chotto",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "お腹が空いた。"
},
"finish_reason": "stop"
}
],
"transcription": "I am hungry",
"source_lang": "en",
"target_lang": "ja",
"balance": {
"free": 1000,
"premium": 0
},
"usage": {
"prompt_tokens": 3,
"completion_tokens": 1,
"total_tokens": 4
}
}
Set stream to "true" to receive the translation as Server-Sent Events instead — see the API reference for the full request and response schema, including the streaming format.
Next steps
- See every form field and response field in the API reference.
- Learn the auth header conventions across services in Authentication.
- See how usage is billed on Pricing.