Getting Started
Quick Start
Integrate AMP into your AI agent in 5 minutes.
1. Get Your API Key
Sign up and get your API key from the AMP dashboard.
💡 Tip: Keep your API key secure. Never commit it to version control.
2. Install the SDK
Choose your language:
TypeScript / JavaScript
npm install @amp-protocol/clientPython
pip install amp-protocol3. Initialise the Client
agent.ts
import { AMP } from '@amp-protocol/client';
const amp = new AMP({
apiKey: process.env.AMP_API_KEY,
});4. Get Context Before Responding
Before your agent responds to a user request, call getContext():
agent.ts
// User asks: "Help me build a login page"
const context = await amp.getContext({
userId: user.id,
task: "build a login page",
metadata: {
timestamp: Date.now(),
source: "chat",
},
});
// AMP returns:
// {
// requestId: "req_abc123",
// suggestedFraming: "micro_task",
// communicationStyle: "brief_directive",
// complexity: "break_into_steps",
// effectiveness: 0.87
// }5. Adapt Your Response
Use the context to personalise your agent's behaviour:
agent.ts
// Option 1: Adapt your system prompt
const systemPrompt = `You are a coding assistant.
Use ${context.communicationStyle} communication.
Frame this task as a ${context.suggestedFraming}.`;
const response = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userQuery },
],
});
// Option 2: Adapt programmatically
if (context.complexity === "break_into_steps") {
response = generateStepByStepGuide(userQuery);
} else {
response = generateDirectSolution(userQuery);
}6. Report the Outcome
After the user interacts with your response, report what happened:
agent.ts
await amp.reportOutcome({
requestId: context.requestId,
started: true, // Did the user start the task?
completed: true, // Did they complete it?
timeToStart: 45, // Seconds until they started
flowState: true, // Did they seem engaged?
satisfaction: 0.9, // Optional: user feedback score
});Complete Example
Here's a full integration example:
agent.ts
import { AMP } from '@amp-protocol/client';
import OpenAI from 'openai';
const amp = new AMP({ apiKey: process.env.AMP_API_KEY });
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
export async function handleUserQuery(
userId: string,
query: string
): Promise<string> {
// 1. Get motivation context
const context = await amp.getContext({
userId,
task: query,
metadata: { timestamp: Date.now() },
});
// 2. Adapt your system prompt
const systemPrompt = `You are a helpful coding assistant.
Communication style: ${context.communicationStyle}
Task framing: ${context.suggestedFraming}
Complexity approach: ${context.complexity}`;
// 3. Generate response
const response = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: query },
],
});
const answer = response.choices[0].message.content;
// 4. Report outcome (in background or after user interaction)
setTimeout(async () => {
await amp.reportOutcome({
requestId: context.requestId,
started: true,
completed: true,
});
}, 30000);
return answer;
}