| | |
| | """ |
| | Script to list available CBORG models using your CBORG_API_KEY. |
| | Usage: |
| | export CBORG_API_KEY=... |
| | python list_cborg_models.py |
| | """ |
| | import os |
| | import sys |
| | from openai import OpenAI |
| |
|
| | def main(): |
| | api_key = os.environ.get('CBORG_API_KEY') |
| | if not api_key: |
| | print("Error: CBORG_API_KEY environment variable not set.") |
| | sys.exit(1) |
| |
|
| | client = OpenAI( |
| | api_key=api_key, |
| | base_url="https://api.cborg.lbl.gov" |
| | ) |
| | try: |
| | response = client.models.list() |
| | print("Available CBORG models:") |
| | print("-" * 80) |
| | for model in response.data: |
| | print(f"\nModel ID: {model.id}") |
| | |
| | |
| | try: |
| | model_details = client.models.retrieve(model.id) |
| | print(f" Created: {model_details.created if hasattr(model_details, 'created') else 'N/A'}") |
| | print(f" Owned by: {model_details.owned_by if hasattr(model_details, 'owned_by') else 'N/A'}") |
| | |
| | |
| | print(f" Available attributes:") |
| | for attr in dir(model_details): |
| | if not attr.startswith('_'): |
| | try: |
| | value = getattr(model_details, attr) |
| | if not callable(value): |
| | print(f" {attr}: {value}") |
| | except: |
| | pass |
| | except Exception as e: |
| | print(f" (Could not retrieve detailed info: {e})") |
| | |
| | print("-" * 80) |
| | except Exception as e: |
| | print(f"Error fetching model list: {e}") |
| | sys.exit(1) |
| |
|
| | if __name__ == '__main__': |
| | main() |
| |
|