| |
| """ |
| Verify Claude model versions and API access |
| """ |
|
|
| import anthropic |
| from datetime import datetime |
|
|
| def log(m): print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] {m}", flush=True) |
|
|
| def verify_claude_models(): |
| """Test Claude API access and available models""" |
| |
| |
| api_key = "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" |
| |
| log("π VERIFYING CLAUDE MODEL VERSIONS...") |
| |
| try: |
| client = anthropic.Anthropic(api_key=api_key) |
| |
| |
| test_models = [ |
| "claude-3-5-sonnet-20241022", |
| "claude-3-5-sonnet-20240620", |
| "claude-3-sonnet-20240229", |
| "claude-3-opus-20240229", |
| "claude-3-haiku-20240307" |
| ] |
| |
| available_models = [] |
| |
| for model in test_models: |
| try: |
| log(f" Testing: {model}") |
| response = client.messages.create( |
| model=model, |
| max_tokens=50, |
| messages=[{"role": "user", "content": "Say hello in one word"}] |
| ) |
| available_models.append(model) |
| log(f" β
AVAILABLE: {model}") |
| |
| except Exception as e: |
| error_msg = str(e) |
| if "not_found" in error_msg: |
| log(f" β NOT FOUND: {model}") |
| elif "authentication" in error_msg: |
| log(f" π AUTH ERROR: {model} - Check API key") |
| else: |
| log(f" β οΈ OTHER ERROR: {model} - {error_msg[:100]}") |
| |
| log(f"\nπ AVAILABLE CLAUDE MODELS:") |
| for model in available_models: |
| log(f" β’ {model}") |
| |
| if available_models: |
| log(f"π― RECOMMENDED MODEL: {available_models[0]}") |
| else: |
| log("β NO MODELS AVAILABLE - Check API key or billing") |
| |
| return available_models |
| |
| except Exception as e: |
| log(f"β CLIENT CREATION FAILED: {e}") |
| return [] |
|
|
| def check_api_quota(): |
| """Check if we have API quota available""" |
| log("\nπ° CHECKING API QUOTA STATUS...") |
| |
| |
| |
| try: |
| client = anthropic.Anthropic(api_key="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") |
| |
| response = client.messages.create( |
| model="claude-3-5-sonnet-20240620", |
| max_tokens=10, |
| messages=[{"role": "user", "content": "Say 'test'"}] |
| ) |
| |
| log("β
API QUOTA: Available - Test call successful") |
| return True |
| |
| except Exception as e: |
| log(f"β API QUOTA: Issue detected - {e}") |
| return False |
|
|
| if __name__ == "__main__": |
| available_models = verify_claude_models() |
| quota_ok = check_api_quota() |
| |
| print(f"\nπ― SUMMARY:") |
| print(f" β’ Available Models: {len(available_models)}") |
| print(f" β’ API Quota: {'β
OK' if quota_ok else 'β Issues'}") |
| print(f" β’ Recommended: Use '{available_models[0] if available_models else 'NO MODEL'}'") |
|
|