Merge pull request #362 from nicho810/feat/cheapaimodel-preset

feat: add cheapaimodel preset to LLM specs
This commit is contained in:
Alexander Myasoedov authored and GitHub committed 2026-11-04 11:49:56 +02:00
commit c53cf3c02a
3 files changed
+67

No files matched your search

+12
View File
@@ -186,6 +186,17 @@ Content-Type: application/json
{"role": "user", "content": "<<PROMPT>>"}
]
}
""",
"""POST https://api.cheapaimodel.ai/v1/chat/completions
Authorization: Bearer $CHEAPAIMODEL_API_KEY
Content-Type: application/json
{
"model": "deepseek-v4-1-flash",
"messages": [
{"role": "user", "content": "<<PROMPT>>"}
]
}
""",
]
@@ -404,6 +415,7 @@ LLM_CONFIGS = [
{"name": "assemblyai", "prompts": 40000, "logo": "/icons/myshell.png"},
{"name": "OpenRouter.ai", "prompts": 40000, "logo": "/icons/openrouter.png"},
{"name": "Runcrate", "prompts": 40000, "logo": "/icons/myshell.png"},
{"name": "cheapaimodel", "prompts": 40000, "logo": "/icons/myshell.png"},
]
LLM_SPECS = [dict(spec=spec, **d) for spec, d in zip(_SPECS, LLM_CONFIGS)]
+13
View File
@@ -197,6 +197,18 @@ Content-Type: application/json
{"role": "user", "content": "<<PROMPT>>"}
]
}
`,
`POST https://api.cheapaimodel.ai/v1/chat/completions
Authorization: Bearer $CHEAPAIMODEL_API_KEY
Content-Type: application/json
{
"model": "deepseek-v4-1-flash",
"messages": [
{"role": "user", "content": "<<PROMPT>>"}
]
}
`,
]
@@ -219,6 +231,7 @@ let LLM_CONFIGS = [
{ name: 'assemblyai', prompts: 40000, logo: fallbackIcon },
{ name: 'OpenRouter.ai', prompts: 40000, logo: '/icons/openrouter.png' },
{ name: 'Runcrate', prompts: 40000, logo: fallbackIcon },
{ name: 'cheapaimodel', prompts: 40000, logo: fallbackIcon },
];
function has_image(spec) {
+42
View File
@@ -0,0 +1,42 @@
import json
import httpx
import pytest
from agentic_security.http_spec import LLMSpec, Modality
from agentic_security.routes._specs import LLM_SPECS
def cheapaimodel_spec() -> LLMSpec:
entry = next(item for item in LLM_SPECS if item["name"] == "cheapaimodel")
return LLMSpec.from_string(entry["spec"])
def test_cheapaimodel_preset_parses_to_chat_completions():
spec = cheapaimodel_spec()
assert spec.method == "POST"
assert spec.url == "https://api.cheapaimodel.ai/v1/chat/completions"
assert spec.headers["Authorization"] == "Bearer $CHEAPAIMODEL_API_KEY"
assert spec.model_name == "deepseek-v4-1-flash"
assert spec.modality == Modality.TEXT
@pytest.mark.asyncio
async def test_cheapaimodel_preset_probe_sends_prompt_as_user_message(monkeypatch):
captured = {}
async def fake_request(self, method, url, headers=None, content=None, timeout=None):
captured.update(method=method, url=url, content=content)
return httpx.Response(200, json={"choices": [{"message": {"content": "ok"}}]})
monkeypatch.setattr(httpx.AsyncClient, "request", fake_request)
response = await cheapaimodel_spec().probe('Say "hi"')
assert response.status_code == 200
assert captured["method"] == "POST"
assert captured["url"] == "https://api.cheapaimodel.ai/v1/chat/completions"
body = json.loads(captured["content"])
assert body["model"] == "deepseek-v4-1-flash"
assert body["messages"] == [{"role": "user", "content": 'Say "hi"'}]