Skip to main content
Use the Perceptron Python SDK to send image, video, and audio messages to the hosted API. These guides use SDK 0.4.0 or later. You do not need a local GPU.

Set up your environment

Create a virtual environment, activate it, and install the client:
On Windows PowerShell, activate with .venv\Scripts\Activate.ps1 and set the key with $env:PERCEPTRON_API_KEY="your-api-key". See Authentication for key configuration and troubleshooting.

Send an image request

Save this as first_request.py. It uses a public sample image and checks that the model finished its answer before printing it:
Run it from the same terminal:
With provider="perceptron", the SDK uses https://api.perceptron.inc/v1 unless you configure a different base_url. It can read PERCEPTRON_API_KEY automatically; the example passes the key explicitly. Requests are not retried automatically. Use the bounded retry example in Error messages when adding retries to your application.

Use a task helper

For a single question, question() builds the messages for you. Use image(), video(), or audio() to identify the media type:
The helper returns a PerceiveResult; the message API returns a ChatCompletion. Both expose text, reasoning, tool calls, completion status, and asset resolution. The message API exposes typed Usage through response.usage; task helpers expose usage as a dictionary through result.usage. Use the message API when you need explicit conversation history or a tool loop.

Build on the example

  • Request basics: reusable functions, message roles, and follow-up questions.
  • Files: upload local media and reuse its file ID.
  • Multiple assets: include several images or videos and interpret asset_idx.
  • Structured outputs: validate a JSON result.
  • Tool calling: execute application functions and return their results.
  • Python FAQs: async requests, annotations, streaming, and common setup problems.