π Introducing MARS8 Series β Four Powerful Variants | Available on All Major Clouds | Learn about the model here
π Introducing MARS8 Series β Four Powerful Variants | Available on All Major Clouds | Learn about the model here
Retrieves the final translated texts from multiple completed translation tasks using a list of run_id values in a single request.
curl --request POST \
--url https://client.camb.ai/apis/translation-results \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"run_ids": [
12345,
6789
]
}
'{}This endpoint delivers the final products of multiple translation processes simultaneously: all your translated texts in one efficient request. Once your translation tasks have completed successfully and youβve received multipleDocumentation Index
Fetch the complete documentation index at: https://docs.camb.ai/llms.txt
Use this file to discover all available pages before exploring further.
run_id values, this endpoint allows you to retrieve all the actual translations that were generated. Think of it as the express pickup counter where you collect several finished translation orders at once, rather than making individual trips for each one.
POST request to this endpoint with an array of run_id values in the request body. Each run_id serves as your claim ticket for a finished translation task. You must provide between 2 and 5 run_id values per request. The system will respond with a structured object containing all your translated texts, organized by their corresponding run_id values.
run_id values for the completed translation tasks you want to retrieve. You must provide between 2 and 5 run_id values per request:
{
"run_ids": [12345, 12346, 12347, 12348]
}
run_ids array must contain between 2 and 5 values. Requests with fewer than 3 or more than 5 run_ids will be rejected with a validation error.run_id:
results: An object where each key is a run_id and each value contains the translation data for that specific tasktexts: Within each result, an array of strings containing the translated output texts, maintaining the same order as the original input for that task{
"12345": {
"texts": [
"Your first translated text from task 12345",
"Your second translated text from task 12345"
]
},
"12346": {
"texts": [
"Your first translated text from task 12346",
"Your second translated text from task 12346",
"Your third translated text from task 12346"
]
},
"12347": {
"texts": [
"Single translated text from task 12347"
]
},
"12348": {
"texts": [
"First text from task 12348",
"Second text from task 12348",
"Third text from task 12348",
"Fourth text from task 12348"
]
}
}
# Welcome to the translation results retriever! πβ¨
# This script will help you get translation results for multiple tasks from the Camb AI API.
# Make sure you have the requests library installed. If not, run: pip install requests π¦
import requests
# Set up the headers for the API request. This includes your API key and the content type. π
# TODO: Replace 'your-api-key' with your actual API key from Camb AI.
headers = {
"x-api-key": "your-api-key", # Replace with your actual API key
"Content-Type": "application/json",
}
# List of run_ids for the completed translation tasks you want to retrieve. π
# TODO: Replace these with your actual run_ids. Must be between 2 and 5 run_ids.
run_ids = [12345, 12346, 12347, 12348] # Example run_ids
def get_bulk_translation_results(run_ids):
"""
Retrieves translations for multiple completed tasks in a single request. π
Args:
run_ids: List of run_id values for completed translation tasks (must be 3-5 items)
Returns:
dict: Dictionary mapping run_ids to their translation results
"""
# Check if the number of run_ids is between 2 and 5. If not, print an error message and return an empty dictionary. β οΈ
if len(run_ids) < 2 or len(run_ids) > 5:
print(
f"β Error: Must provide between 2 and 5 run_ids. You provided {len(run_ids)}."
)
return {}
print(f"π Retrieving translations for {len(run_ids)} completed tasks...")
# Prepare the payload for the API request. This includes the list of run_ids. π¦
payload = {"run_ids": run_ids}
try:
# Define the API endpoint URL. π
API_URL = "https://client.camb.ai/apis/translation-results"
# Make the POST request to the API endpoint to retrieve the translation results. π
response = requests.post(API_URL, headers=headers, json=payload)
# Check if the request was successful. If not, an exception will be raised. β
response.raise_for_status()
# Parse the JSON response to get the translation results. π
results = response.json()
print(f"π Successfully retrieved translations for {len(results)} tasks!")
return results
except requests.exceptions.RequestException as e:
print(f"π’ Oops! There was an error retrieving the translation results: {e}")
return {}
# Now, let's retrieve the translation results for the provided run_ids. π
translation_results = get_bulk_translation_results(run_ids)
# Check if any results were retrieved. If not, print a message. π€
if not translation_results:
print(
"π No translation results were retrieved. Please check your run_ids and API key."
)
else:
# Process the retrieved translation results and print them. π¨οΈ
for run_id in translation_results:
translations = translation_results.get(run_id, {}).get("texts", [])
print(f"\nπ Run ID {run_id} has {len(translations)} translations:")
for i, translation in enumerate(translations):
print(f" {i+1}. {translation} π")
# What's next? You could save these results to a file or use them in your next project! π
run_id values per requestrun_id values per requestrun_id list into chunks of 3-5 items# Example: Processing larger datasets
all_run_ids = [12345, 12346, 12347, 12348, 12349, 12350, 12351, 12352]
# Split into chunks of 3-5 run_ids
def chunk_run_ids(run_ids, chunk_size=5):
"""Split run_ids into chunks of specified size (3-5)."""
chunks = []
for i in range(0, len(run_ids), chunk_size):
chunk = run_ids[i:i + chunk_size]
if len(chunk) >= 2: # Ensure minimum chunk size
chunks.append(chunk)
elif chunks: # Add remaining items to last chunk if possible
chunks[-1].extend(chunk)
return chunks
# Process in batches
chunks = chunk_run_ids(all_run_ids)
all_results = {}
for i, chunk in enumerate(chunks):
print(f"Processing batch {i+1}/{len(chunks)}: {len(chunk)} run_ids")
batch_results, failed_ids = get_bulk_translation_results_with_error_handling(chunk)
all_results.update(batch_results)
The x-api-key is a custom header required for authenticating requests to our API. Include this header in your request with the appropriate API key value to securely access our endpoints. You can find your API key(s) in the 'API' section of our studio website.
An array of unique positive integers, each representing the ID of a specific run. You must provide between 2 and 5 IDs, and all IDs must correspond to the same run type (e.g., all text-to-speech or all dubbing runs).
2 - 5 elements[12345, 6789]Successful Response
An object containing the results of one to five transcription runs. Each key in the object is a unique identifier for a run, and the corresponding value is the translation output.
curl --request POST \
--url https://client.camb.ai/apis/translation-results \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"run_ids": [
12345,
6789
]
}
'{}