Validate that an E2B API key has the expected ``e2b_`` prefix followed by hex characters. Raises ``AuthenticationException`` otherwise.
(api_key: str)
| 86 | |
| 87 | |
| 88 | def validate_api_key(api_key: str) -> None: |
| 89 | """Validate that an E2B API key has the expected ``e2b_`` prefix |
| 90 | followed by hex characters. Raises ``AuthenticationException`` otherwise. |
| 91 | """ |
| 92 | if not _API_KEY_PATTERN.match(api_key): |
| 93 | raise AuthenticationException( |
| 94 | 'Invalid API key format: expected "e2b_" followed by hex ' |
| 95 | f'characters (e.g. "{_API_KEY_EXAMPLE}"). ' |
| 96 | "Visit the API Keys tab at https://e2b.dev/dashboard?tab=keys to get your API key." |
| 97 | ) |
| 98 | |
| 99 | |
| 100 | class ApiClient(AuthenticatedClient): |
searching dependent graphs…