image-to-text endpoint allows you to analyze an image and ask questions about its content via the WetroCloud API.
Request Example
from wetro import Wetrocloud
# Initialize the Wetrocloud client
client = Wetrocloud(api_key="your_api_key")
# Extract text from an image and answer questions about it
ocr_response = client.image_to_text(
image_url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTQBQcwHfud1w3RN25Wgys6Btt_Y-4mPrD2kg&s",
request_query="What animal is this?"
)
print(ocr_response)
import Wetrocloud from "wetro-sdk";
// Initialize the Wetrocloud client
const client = new Wetrocloud({
apiKey: "your_api_key"
});
const imageUrl = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTQBQcwHfud1w3RN25Wgys6Btt_Y-4mPrD2kg&s';
const query = 'What animal is this?';
// Extract text from an image and answer questions about it
const response = await client.imageToText({
image_url: imageUrl,
request_query: query
});
console.log("Image to text:", response);
curl --request POST \
--url https://api.wetrocloud.com/v1/image-to-text/ \
--header 'Authorization: Token <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTQBQcwHfud1w3RN25Wgys6Btt_Y-4mPrD2kg&s",
"request_query": "What animal is this?"
}'
Response Example
{
"response": "This is a dog, specifically a Labrador Retriever.",
"tokens": 1594,
"success": true
}
| Field | Description |
|---|---|
response | Conversational response to the query. |
tokens | Number of tokens used for processing. |
success | Indicates whether the query was successful. |