The Proxy API (/proxy) forwards provider-native requests; coverage depends on which provider account and endpoint you use. It does not use a single consolidated provider matrix like the translated APIs. See Supported APIs for feature matrices on those endpoints.The Proxy API allows you to route requests directly to AI provider endpoints through TrueFoundry AI Gateway without any translation logic. This means you can use provider-native request and response formats while still benefiting from TrueFoundry’s features like logging, rate limiting, and budget management.TrueFoundry Proxy Endpoint routes your request to the appropriate provider and returns the provider’s response without modifying it, preserving the native request/response format.
About this example: This image generation request would work perfectly fine through TrueFoundry’s standard inference API. This example specifically demonstrates how to use the proxy route to make requests with provider-native formats while proxying requests via TrueFoundry AI Gateway.
That’s it! The proxy API works with your existing OpenAI SDK code. For more configuration options and other providers, see the detailed examples below.
from anthropic import AnthropicBASE_URL = "{GATEWAY_BASE_URL}/proxy"API_KEY = "your-truefoundry-api-key"# Configure Anthropic client with TrueFoundry settingsclient = Anthropic( api_key=API_KEY, base_url=BASE_URL)# Make requests with your TrueFoundry model name in the request bodyresponse = client.messages.create( model="anthropic-main/claude-3-5-sonnet-20241022", # TrueFoundry model name max_tokens=1024, messages=[ {"role": "user", "content": "Tell me a joke about programming"} ])print(response.content)
import requestsurl = "{GATEWAY_BASE_URL}/proxy/v1/ranking"headers = { "Content-Type": "application/json", "Authorization": "Bearer your-truefoundry-api-key", "X-TFY-LOGGING-CONFIG": '{"enabled": true}'}payload = { "model": "custom-provider-main/llama-3.2-nemoretriever-500m-rerank-v2", "query": { "text": "What is machine learning?" }, "passages": [ {"text": "Machine learning is a subset of artificial intelligence"}, {"text": "The weather is nice today"}, {"text": "Python is a programming language"} ]}response = requests.post(url, headers=headers, json=payload)print(response.json())
import requestsurl = "{GATEWAY_BASE_URL}/proxy/v1/ranking"headers = { "Content-Type": "application/json", "Authorization": "Bearer your-truefoundry-api-key", "X-TFY-LOGGING-CONFIG": '{"enabled": true}', "x-tfy-model-name": "custom-provider-main/llama-3.2-nemoretriever-500m-rerank-v2"}payload = { "query": { "text": "What is artificial intelligence?" }, "passages": [ {"text": "AI is a branch of computer science"}, {"text": "Machine learning is a subset of AI"}, {"text": "Today is a sunny day"} ]}response = requests.post(url, headers=headers, json=payload)print(response.json())
import requestsurl = "{GATEWAY_BASE_URL}/proxy/v1/ranking"params = { "tfyModelName": "custom-provider-main/llama-3.2-nemoretriever-500m-rerank-v2"}headers = { "Content-Type": "application/json", "Authorization": "Bearer your-truefoundry-api-key", "X-TFY-LOGGING-CONFIG": '{"enabled": true}'}payload = { "query": { "text": "Where is New Delhi?" }, "passages": [ {"text": "New Delhi is capital of India"}, {"text": "The sky is blue"}, {"text": "Paris is the capital of France"} ]}response = requests.post(url, headers=headers, json=payload, params=params)print(response.json())
All provider endpoints can be proxied through TrueFoundry AI Gateway for basic routing, but won’t include advanced features like detailed logging, rate limiting, and budget management.
For all other proxy endpoints: You can simply pass the TrueFoundry provider name via headers (x-tfy-provider-name) or query parameters (tfyProviderName) along with the actual model ID (if required), and the proxy will route your request correctly without requiring the full TrueFoundry model name format.
import openaiclient = openai.OpenAI( api_key="your-truefoundry-api-key", base_url="{GATEWAY_BASE_URL}/proxy", default_headers={ "x-tfy-provider-name": "openai-main" })response = client.images.generate( model="dall-e-3", # Actual model ID prompt="a serene mountain landscape with aurora borealis", n=1, size="1024x1024")print("Image URL:", response.data[0].url)
Extract text from documents while maintaining structure and formatting (headers, paragraphs, lists, tables). Returns markdown format and supports multiple formats including PDFs, images (png, jpeg, avif), and office documents (pptx, docx).Learn more about Mistral Document AI OCR capabilities.