Install
Works with Drupal: ^10.5 || ^11.2Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
Second beta of the 1.1.x line. It brings the provider in line with changes in TypeSafe's official SDKs since their
first public release (Python 0.6.0 to 0.7.2, JavaScript 0.6.0) and fixes an API key leak. No configuration changes or
database updates are needed.
Requirements
- Drupal
^10.5 || ^11.2 - AI
^1.6. Until AI 1.6.0 is released, use AI's1.6.xdevelopment branch:
composer require 'drupal/ai:1.6.x-dev@dev' 'drupal/ai_provider_typesafeai:1.1.0-beta2'
Fixed: API key leak
In 1.1.0-beta1, an API key with a trailing newline made the HTTP library reject the Authorization header
with an error message that contained the full key. Such keys are common with file- or environment-backed Key providers.
That message was shown in the settings form and written to the log.
Keys are now trimmed and checked before any request. A key that is empty, or that contains whitespace, control or
non-ASCII characters, fails with AiSetupFailureException, and error messages never contain the key.
If your key value could have ended with a newline, search your logs for is not valid header value. If you
find it, rotate the key.
New
- Request IDs. TypeSafe's
x-typesafe-request-idis quoted in API error messages, for
exampleTypeSafe API error (HTTP 422, request ID req_…). It is also returned asrequest_idin the metadata of Decision, Text classification and Moderation outputs, and as thetypesafeai_request_iddebug value. Quote it in TypeSafe support requests. - AI gateway documentation. The README lists the API base URLs for the Vercel AI Gateway and the
Pydantic AI Gateway. Enter them under Advanced → API base URL, including/v1. OpenRouter is not supported yet: its model list uses a different format, so the settings form cannot verify the key.
Changed
- Missing-key errors. The API reports a missing key as HTTP 403 with
authentication_error. This now maps toAiSetupFailureException, like 401, instead of
AiAccessDeniedException. - Retries follow the SDKs' current default policy.
- A call stops retrying when the next delay would take it past 30 seconds in total. An attempt that hit AI's
request timeout (60 seconds by default) is therefore no longer retried twice inside the same web request. retry-after-msis honoured, and takes precedence overRetry-After. Both stay capped at 5 seconds.- Jitter now only shortens backoff delays, so no delay exceeds 5 seconds.
- A call stops retrying when the next delay would take it past 30 seconds in total. An attempt that hit AI's
For developers
TypeSafeAiClient's constructor now throwsAiSetupFailureExceptionfor an unusable key and\InvalidArgumentExceptionfor out-of-range retry settings. It gains optional trailing
$retryBudgetMs(default 30000;NULLdisables it) and$clockarguments. Existing positional arguments are unchanged.TypeSafeAiClientalso gainsnormalizeApiKey(),getLastRequestId(), and theREQUEST_ID_HEADERandDEFAULT_RETRY_BUDGET_MSconstants.- New tests cover key handling, request IDs, the 403 mapping and the retry policy. A regression test checks that score
levels are always sent as a JSON list. The SDKs made that form mandatory in 0.6.0; this provider already sent it.
Tested with
AI 1.6.x at d6c0eb17b, Drupal 11.4 and PHP 8.4. A live smoke battery of 33 checks passed against jev-latest (jev-1.13.0).
Commits since 1.1.0-beta1
- Document AI gateway base URLs (f99a560)
- Test that score criteria are always sent as a JSON list (ccc6285)
- Align retries with the TypeSafe SDK default retry policy (b4bdc2b)
- Validate the API key before use so errors never echo it (4e9e13b)
- Map 403 authentication_error responses to AiSetupFailureException (8bdbace)
- Expose TypeSafe request ID in errors and output metadata (6106d0e)
- Update changelog wording for AI's input validation convention (1cbc126)