🚀 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 current status of a story translation task using the specified task_id.
curl --request GET \
--url https://client.camb.ai/apis/translated-story/{task_id} \
--header 'x-api-key: <api-key>'{
"run_id": 123
}Monitor the progress of your story translation tasks with our dedicated status tracking endpoint. This essential companion to our translation service lets you check on your story’s transformation journey in real-time, providing detailed information about which stage of the process your content has reached. By polling this endpoint, you can keep track of your translation progress and detect any issues that might arise during processing. This endpoint works in conjunction with theDocumentation Index
Fetch the complete documentation index at: https://docs.camb.ai/llms.txt
Use this file to discover all available pages before exploring further.
/translated-story/{run_id} endpoint, which initiates the translation process and provides the task_id needed for status checks.
import requests
import json
import time
# Your API authentication
headers = {
"x-api-key": "your-api-key", # Replace with your actual API key
"Content-Type": "application/json"
}
def check_translation_status(task_id):
"""
Polls the status endpoint to track a story translation task's progress.
Continues checking until the task reaches a terminal state.
Parameters:
- task_id: The unique identifier returned when the translation request was submitted
Returns:
- The final status data when a terminal state is reached, or None if an error occurs
"""
if not task_id:
print("Error: No task ID provided")
return None
# Define the possible final states of a translation task
terminal_states = ["SUCCESS", "ERROR", "TIMEOUT", "PAYMENT_REQUIRED"]
current_status = None
while current_status not in terminal_states:
try:
# Make the status request
response = requests.get(
f"https://client.camb.ai/apis/translated-story/{task_id}",
headers=headers
)
# Verify the request was successful
response.raise_for_status()
# Extract the status information
status_data = response.json()
current_status = status_data.get("status")
# Display current progress information
print(f"Status: {current_status}")
# Handle different status states
if current_status == "SUCCESS":
print("Translation completed successfully!")
print(f"Translated story URL: {status_data.get('story_url')}")
return status_data
elif current_status == "ERROR":
print(f"Translation failed: {status_data.get('error_message')}")
return status_data
elif current_status == "TIMEOUT":
print("Translation process timed out")
return status_data
elif current_status == "PAYMENT_REQUIRED":
print("Additional payment is required to complete this translation")
return status_data
elif current_status == "PENDING":
# Task is still in progress, wait before checking again
print("Translation in progress...")
if status_data.get('progress'):
print(f"Progress: {status_data.get('progress')}%")
if status_data.get('current_stage'):
print(f"Current stage: {status_data.get('current_stage')}")
# Wait before next check to avoid excessive requests
time.sleep(30) # Poll every 30 seconds
else:
# Unexpected status, wait and try again
print(f"Received status: {current_status}")
time.sleep(30)
except requests.exceptions.RequestException as e:
print(f"Error checking translation status: {e}")
if hasattr(e, 'response') and e.response is not None:
print(f"Response content: {e.response.text}")
return None
return status_data
# Example usage with a task_id from a previous translation request
task_id = "your_task_id" # Replace with your actual task ID
final_status = check_translation_status(task_id)
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.
A unique identifier for the task. This is used to query the status of the translated story task that is running. It is returned when a create request is made for a translated story.
curl --request GET \
--url https://client.camb.ai/apis/translated-story/{task_id} \
--header 'x-api-key: <api-key>'{
"run_id": 123
}