MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / get_openai_models

Function get_openai_models

web/pgadmin/llm/__init__.py:514–543  ·  view source on GitHub ↗

Fetch available OpenAI models. Returns models that support function calling.

()

Source from the content-addressed store, hash-verified

512@blueprint.route("/models/openai", methods=["GET"], endpoint='models_openai')
513@pga_login_required
514def get_openai_models():
515 """
516 Fetch available OpenAI models.
517 Returns models that support function calling.
518 """
519 from pgadmin.llm.utils import get_openai_api_key, get_openai_api_url
520
521 api_key = get_openai_api_key()
522 api_url = get_openai_api_url()
523 if not api_key and not api_url:
524 return make_json_response(
525 data={'models': [], 'error': 'No API key configured'},
526 status=200
527 )
528
529 try:
530 models = _fetch_openai_models(api_key, api_url)
531 return make_json_response(data={'models': models}, status=200)
532 except LLMApiError as e:
533 return make_json_response(
534 data={'models': [], 'error': str(e)},
535 status=200
536 )
537 except Exception:
538 return make_json_response(
539 data={'models': [],
540 'error': 'Failed to fetch OpenAI models. '
541 'Check the API key and URL configuration.'},
542 status=200
543 )
544
545
546@blueprint.route(

Callers

nothing calls this directly

Calls 4

get_openai_api_keyFunction · 0.90
get_openai_api_urlFunction · 0.90
make_json_responseFunction · 0.90
_fetch_openai_modelsFunction · 0.85

Tested by

no test coverage detected