OpenAI SDK
Use the standard OpenAI client with the AI Gateway base URL and your TrueFoundry API key. See Chat Completions - Getting Started for the full example:Google Gen AI SDK
The Google Gen AI SDK can be used with Gemini and Vertex AI via the AI Gateway by setting a custom base URL.Model ID must match the model name: When using the Google Gen AI SDK with the AI Gateway, the model’s display name in TrueFoundry must match the model ID, because the AI Gateway authorizes your API key against the model. You only need to pass the actual model ID (e.g.
gemini-2.5-flash) in your request.Routing configuration is not supported when using the Google Gen AI SDK with the AI Gateway.
{providerAccountName} with your Gemini or Vertex AI model account name from the AI Gateway.
Anthropic SDK
Use the Anthropic client with the AI Gateway base URL and your TrueFoundry API key to call Claude models:boto3 SDK (AWS Bedrock Runtime)
Useboto3 with the Bedrock Runtime client when you want Bedrock-native APIs (converse, converse_stream, invoke_model, invoke_model_with_response_stream) through the AI Gateway.
Set your endpoint to the AI Gateway Bedrock proxy and pass your TrueFoundry API key as AWS_BEARER_TOKEN_BEDROCK.
Anthropic models with invoke_model*
For Anthropic models, Bedrock invoke_model and invoke_model_with_response_stream should use Anthropic Messages API fields:
- Add
anthropic_version(for example,bedrock-2023-05-31) - Add
max_tokens - Use typed content blocks:
{"type": "text", "text": "..."}
content to avoid validation errors, for example: messages.0.content.0.type: Field required.
LangChain AWS SDK
You can also uselangchain_aws with the TFY AI Gateway Bedrock endpoint: