provider-scaffolding
Skill17 starsChanged 4 months agoMITView on GitHub
Instructions and best practices for scaffolding and implementing new provider adapters in @free-ai-gateway/core.
- Reads credentials
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- free-ai-gatewaySkill
- mcp-integrationSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use this skill whenever an agent needs to add a new AI provider adapter into @free-ai-gateway/core.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Provider Scaffolding Skill
Use this skill whenever an agent needs to add a new AI provider adapter into @free-ai-gateway/core.
Step-by-Step Scaffolding Procedure
1. Create Adapter Class
In packages/core/src/providers/<provider-id>.ts:
import { BaseProvider } from "./base-provider";
import { ProviderModel, UnifiedRequest, UnifiedResponse } from "../types/contracts";
import { ProviderError } from "../errors/errors";
export class NewProviderAdapter extends BaseProvider {
public static readonly providerId = "new_provider";
async invoke(request: UnifiedRequest, model: ProviderModel): Promise<UnifiedResponse> {
const apiKey = this.getApiKey("NEW_PROVIDER_API_KEY");
if (!apiKey) {
throw new ProviderError("Missing NEW_PROVIDER_API_KEY", 401);
}
const { data } = await this.post(
"chat/completions",
{
...request.payload,
model: model.id,
},
{
headers: {
Authorization: `Bearer ${apiKey}`,
},
}
);
return {
servedBy: {
provider: this.config.id,
model: model.id,
},
data,
};
}
}2. Add Configuration to packages/core/src/config/providers.json
{
"id": "new_provider",
"name": "New Provider",
"auth": "api_key",
"base_url": "https://api.newprovider.ai/v1",
"limit_scope": "account",
"openai_compatible": true,
"confidence": "official",
"models": [
{
"id": "model-v1",
"capabilities": ["text", "tool_calling"],
"limits": {
"rpm": 60,
"rpd": 1000
}
}
]
}3. Export in packages/core/src/providers/index.ts & packages/core/src/index.ts
Export the class so ProviderLoader and downstream packages can consume it:
// in packages/core/src/providers/index.ts
export { NewProviderAdapter } from "./new-provider";
// in packages/core/src/index.ts
export { NewProviderAdapter } from "./providers";4. Verify with Tests
npm test --workspace=@free-ai-gateway/coreDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

