code: def call_api(
      prompt: Union[str, list[str]],
      model_name: OpenAIModel,
      api_params: Optional[APIParameters] = None,
  ) -> requests.Response:
      # dodgy error handling and retry code
      count = 0
      max_retries = 25
      while True:
          count += 1
          if count >= max_retries:
              raise ValueError(
                  f"Retried too many times ({max_retries}), got error: {response_json['error']}"
              )
          response = _call_api(prompt, model_name, api_params)
          response_json = response.json()
          if response.status_code != 200:
              logging.info(
                  f"Retrying after error {response.status_code}: {response_json['error']}"
              )
          else:
              break
      return response
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from dataclasses import asdict, dataclass
  import logging
  import os
  from typing_extensions import Literal
  import requests
  from datetime import timedelta
  from typing import Optional, Union
  from ratelimit import sleep_and_retry, limits
label_desc: Use image node_id 1 for calling a global function with example usage: call_api(prompt, model_name, api_params) and returns: response