Get started with DWS AI Gateway API
Send your first text request to https://api.nutrient.io/ai/v1/responses using a DWS API key enabled for AI Gateway.
1. Set up access
Create an account in the Nutrient dashboard(opens in a new tab) or sign in to your existing DWS account. Open the AI Gateway dashboard(opens in a new tab). If AI Gateway is unavailable for your organization, contact Nutrient to enable access.
Open API keys(opens in a new tab) and create or copy a key with access to AI Gateway. A key restricted to another product does not grant AI Gateway access.
Live keys start with pdf_live_. Test keys start with pdf_test_, accept text only, and do not consume your included usage.
Keep keys on your server. Do not embed them in browser or mobile applications. See security and privacy for data-handling details.
2. Set your API key
Set an environment variable in the terminal where you run the examples. Replace the placeholder with your key:
export NUTRIENT_API_KEY="your_api_key_goes_here"3. Send a request
The following examples use the nutrient-s model with the Responses API. The prompt includes the contract text to summarize.
curl --fail-with-body https://api.nutrient.io/ai/v1/responses \ -H "Authorization: Bearer $NUTRIENT_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "nutrient-s", "input": "Summarize this obligation: The supplier must deliver the report by 30 November and notify the customer of delays within two business days." }'Install the OpenAI SDK with npm install openai, then save this example as gateway.mjs. Run it with node gateway.mjs in the same terminal.
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.NUTRIENT_API_KEY, baseURL: "https://api.nutrient.io/ai/v1",});
try { const response = await client.responses.create({ model: "nutrient-s", input: "Summarize this obligation: The supplier must deliver the report by 30 November and notify the customer of delays within two business days.", }); console.log(response.output_text);} catch (error) { console.error("AI Gateway request failed:", error.status, error.message); process.exitCode = 1;}Install the OpenAI SDK with python -m pip install openai, then save this example as gateway.py. Run it with python gateway.py in the same terminal.
import osfrom openai import OpenAI, APIError
client = OpenAI( api_key=os.environ["NUTRIENT_API_KEY"], base_url="https://api.nutrient.io/ai/v1",)
try: response = client.responses.create( model="nutrient-s", input="Summarize this obligation: The supplier must deliver the report by 30 November and notify the customer of delays within two business days.", ) print(response.output_text)except APIError as error: print(f"AI Gateway request failed: {error}") raise4. Read the result
Read the generated text from the OpenAI SDK’s output_text helper. See the API reference(opens in a new tab) for the full response. Generated wording varies between requests. Review the result before using it in an automated workflow.
If the request fails, use errors and limits to interpret the status and error code. A 403 can indicate a key without AI Gateway permission; a 404 can indicate unavailable account access or an unknown model.
Next steps
- Choose a model and API — Pick a model, and Responses or Chat Completions.
- API reference(opens in a new tab) — Request and response schemas, limits, and error codes.
- Decision API — Get probabilities for structured decisions.
- Pricing — Estimate token costs and review plan options.