Get API

GET API · Developer integrations

How a Python service can call multiple models reliably

A Python service can point a compatible client at https://relay-api.getapi.pro/v1, read its API key from a protected environment variable, and use a catalog model name in each request. Production code should also set connection and read timeouts, cap retries, distinguish retryable failures, validate response structure, and keep complete credentials and sensitive prompts out of logs.

Separate configuration from business logic

Read the base URL, credential, and default model from configuration instead of hardcoding them inside application modules. This allows model changes without rewriting business behavior and keeps secrets out of source control.

  • Read credentials from an environment or secret store
  • Validate required configuration at startup
  • Maintain allowed model names centrally

Put a ceiling on network recovery

Unlimited retries multiply both cost and latency. Retry only confirmed transient failures with a maximum count and backoff, and enforce an overall request deadline. Authentication and invalid-input errors should surface immediately.

  • Set connection and read timeouts separately
  • Cap attempts and total elapsed time
  • Log error categories without complete prompts

Treat model output as untrusted input

A request for JSON does not guarantee valid structure. Apply schema validation, length limits, and business constraints before output reaches a database or automated action.

  • Use a safe error state for parse failures
  • Constrain enums and numeric ranges
  • Require confirmation for high-risk actions

Frequently asked questions

What base_url should a Python client use?

Use https://relay-api.getapi.pro/v1; a compatible chat method then calls /chat/completions beneath it.

Can the API key be written in a Python file?

It should not be. Use an environment variable or secret manager and keep local secret files out of version control.

Which errors should be retried automatically?

Retry only confirmed transient network, rate-limit, or service failures. Correct authentication and input errors before trying again.

Business inquiries: business@honeykid.cn