Skip to main content

Basic Usage

After setting your API key, you can optimize prompts easily. Here’s a quick example showing how to optimize a prompt and inspect additional metadata returned by the API:
  • Python
  • JavaScript
  • cURL
from sqwishai import Sqwish
import os

sqwish_client = Sqwish(os.environ.get("SQWISH_API_KEY"))

input_prompt = "Write a haiku about recursion in programming."
response = sqwish_client.text.optimize(input_prompt)

Response Format

The API returns a JSON response with the following structure:
{
  "message": "The optimized text prompt",
  "tokens_reduced": 150
}
Where:
  • message: The optimized version of your input text
  • tokens_reduced: Number of tokens saved by the optimization

Advanced Usage

For more complex scenarios and direct REST API calls, see the API Reference section.