Quickstart¶
Get from zero to your first analysis result in a few minutes.
1. Create a project and API key¶
Log in to the Portal and click New project on the home page (or Add project in the project switcher). Choose Blank project, enter a name and click Create project. To explore a ready-made setup first, pick one of the Example Projects instead.
Then go to Settings → API keys, click New API key, and copy the key — it is only shown once.
Your key looks like: l2-3756a877ccc9c9f1-78debf03cb49...
2. Configure a model provider¶
Several features call an LLM on your behalf — your application, building Instruction Adherence graphs, the Guardrails module, and Red Teaming. Configure at least one LLM service so these features work.
On the LINK2AI cloud, the Included models under Settings → Models work right away and you can skip this step. To use your own LLM service, go to Settings → Models and:
- Click Add Provider and enter any OpenAI-compatible endpoint — a Name, the Base URL (e.g.
https://api.openai.com/v1), and the provider API Key. - Click Add Model in the General-purpose models card, enter a Display Name and the exact Model ID (e.g.
gpt-4o-mini), then select the Provider you added in the first step, or any other.
See Models and Providers for details.
3. Describe your application¶
An Application describes the LLM app you want to test and monitor. It is the target used by Red Teaming, the Playground, Off-Topic Detection, and the Instruction Adherence module. Your project already has one — creating the project created it — so this step fills it in.
Open Application in the sidebar and complete:
- Name and Description.
- Type — a System prompt + model, a Chat completions endpoint or a Chatkit server.
- For a system prompt + model app: select a general purpose Model (required, from step 2), provide the System Prompt (required) and optionally a Temperature and Additional Parameters (JSON).
- For a chat completions endpoint app: select the Endpoint (required, registered in step 2 with Add Model in the Application models card).
- For a Chatkit app: provide the Chatkit URL.
Click Save. Then fill in the Application Context card below: select a model and click Propose (or Probe) to let it describe your application, review the fields and save again. The more precise the context, the better red teaming, Instruction Adherence and Off-Topic Detection work. See Application Context.
4. Enable at least one module¶
In the Portal, open Runtime Analysis in the sidebar and set at least one module to Included in Response mode. A good starting point:
| Module | Suggested mode |
|---|---|
usage |
Included in Response |
harmful_content |
Included in Response |
malicious_intent |
Included in Response |
5. Make your first request¶
Analyze a user message¶
curl -X POST https://api.link2.ai/v1/analyzeInput \
-H "Authorization: Bearer $LINK2AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "How do I reset my password?"}
],
"model": "gpt-4o-mini"
}'
Response¶
{
"results": {
"usage": {
"status": "success",
"secure": true,
"duration_ms": 1.2,
"result": {
"input_tokens": 24,
"output_tokens": null,
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "How do I reset my password?"}
],
"model": "gpt-4o-mini"
},
"cache_hit": null,
"error_message": null
},
"harmful_content": {
"status": "success",
"secure": true,
"duration_ms": 38.4,
"result": {
"categories": {
"harassment": 0.0003,
"violence": 0.0001
}
},
"cache_hit": null,
"error_message": null
},
"malicious_intent": {
"status": "success",
"secure": true,
"duration_ms": 45.1,
"result": {
"message_labels": [
{"label": "SAFE", "score": 0.999}
]
},
"cache_hit": null,
"error_message": null
}
},
"module_errors": false,
"secure": true
}
The top-level secure: true means no security module flagged this interaction. Each module result also has its own secure field.
6. Analyze the LLM response¶
After you get a response from the LLM, send it back for output analysis. Include the full conversation including the assistant message:
curl -X POST https://api.link2.ai/v1/analyzeOutput \
-H "Authorization: Bearer $LINK2AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "How do I reset my password?"},
{"role": "assistant", "content": "You can reset your password by clicking Forgot Password on the login page."}
],
"model": "gpt-4o-mini"
}'
7. Use the proxy instead (optional)¶
If you use the OpenAI Python SDK, switching to proxy mode requires two lines:
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.link2.ai/openai", # (1) point at the Controller
api_key=os.environ["OPENAI_API_KEY"],
default_headers={"LINK2AI-API-KEY": os.environ["LINK2AI_API_KEY"]}, # (2) add key
)
response = client.chat.completions.create(
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "How do I reset my password?"},
],
model="gpt-4o-mini",
)
# Normal OpenAI response, plus analysis
print(response.choices[0].message.content)
print("Secure:", response.input_analysis["secure"], response.output_analysis["secure"])
The proxy handles both analyzeInput and analyzeOutput automatically around the LLM call.
8. Run a red team test¶
Proactively probe your application with adversarial attacks before shipping.
- Open Red Teaming and create a campaign. It tests the application you defined in step 3. Select an adversarial model in the Campaign step.
- In the Attack Sources step, click Recommend attacks to get attacks chosen for your application, review the plan and apply it.
- In the Dataset step, click Generate dataset to produce the adversarial test cases.
- In the Evaluate step, start a run. Each run tests your application both with and without guardrails so you can measure how many attacks your configuration blocks.
See Red Teaming for the full workflow.
Next steps¶
- API Reference — full endpoint and schema documentation
- Configuration — configure modules and understand their output
- Red Teaming — adversarially test your application