Metadata-Version: 2.4
Name: promptledger-openai-compatible
Version: 0.1.0
Summary: Optional OpenAI-compatible text evaluation provider for PromptLedger
Author: PromptLedger Contributors
License-Expression: MIT
Project-URL: Repository, https://github.com/Ertugrulmutlu/promptledger
Project-URL: Documentation, https://github.com/Ertugrulmutlu/promptledger/blob/main/docs/plugin-sdk.md
Project-URL: Issues, https://github.com/Ertugrulmutlu/promptledger/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: promptledger<0.9,>=0.8
Dynamic: license-file

# PromptLedger OpenAI-compatible provider

Optional SDK v1 provider for PromptLedger 0.8.x; Python standard library only. Core remains offline-capable without it. Supports text Chat Completions and model listing. Presets: `openrouter`, `openai`, `deepseek`, `groq`, `lmstudio` (127.0.0.1:1234), `vllm` (127.0.0.1:8000), and `custom` (explicit `base_url`). Only protocol compatibility is intended; individual models and providers may differ.

Install with `python -m pip install promptledger-openai-compatible`. From a source checkout, install Core first, then use `python -m pip install -e ./plugins/openai-compatible --no-deps`. Use `promptledger plugins conformance openai-compatible --confirm` to verify structural compatibility.

## Remote calls

Set the appropriate environment variable: `OPENROUTER_API_KEY`, `OPENAI_API_KEY`, `DEEPSEEK_API_KEY`, `GROQ_API_KEY`, `LMSTUDIO_API_KEY`, `VLLM_API_KEY` or `PROMPTLEDGER_API_KEY` (custom only). Never include keys in options, prompts, files or command arguments. Keys are not persisted by this plugin. Local loopback services may omit credentials.

Example options file for `promptledger plugins run openai-compatible evaluate --options-file options.json --confirm`:

```json
{
  "id": "api-demo", "ref": 1,
  "provider": "openrouter", "allow_remote": true,
  "model": "REPLACE_WITH_MODEL_ID", "expected": "HELLO", "max_tokens": 1024
}
```

Create `api-demo` first. Use a model ID available to your account. For model listing use `healthcheck` and an options file containing only `provider` and `allow_remote` (plus `base_url` for custom). Presets cannot be redirected to custom endpoints. HTTPS is required except literal loopback; proxies and redirects are disabled. The endpoint must be trusted, including loopback servers which may themselves forward requests to cloud services. Remote calls require explicit consent and can cost money; there is no automatic cloud fallback or retry. Token caps are not a monetary budget. The provider does not control remote logging, routing or retention.

## Results

A case-sensitive substring check is recorded against the exact saved version. The selected prompt is sent as a user message; the expected text stays local. A normal textual completion is required; incomplete/refused/nontext responses cause an error rather than a saved failed check. Tokens and OpenRouter-reported USD cost are recorded only when present; no estimated charges. Raw response and API key are not stored. Suite is `openai-compatible:<preset>`; `dataset_hash` identifies the test protocol (expected text, endpoint, requested model, output limit and message role), rather than a benchmark dataset. Use identical settings for comparisons. Provider-side routing or model changes can still affect reproducibility. Secret detection is heuristic, not a guarantee. The SDK is not sandboxed. The dashboard supports the fixed local/cloud presets, explicit model discovery and per-run remote approval. Custom endpoints remain CLI-only. DeepSeek Flash and OpenRouter Free passed live CLI smoke tests; other provider/model combinations are not all live-tested. Dynamic OpenRouter routing IDs are smoke-test only and cannot be used for regression gates or guarded promotion. Batch jobs are not executed.

For DeepSeek and OpenRouter, optionally set `"thinking": false` to request non-thinking mode on models supporting it. This option is included in comparison identity. The remote service controls actual token usage.

See the [integration guide](https://github.com/Ertugrulmutlu/promptledger/blob/main/docs/integrations.md) and [SDK guide](https://github.com/Ertugrulmutlu/promptledger/blob/main/docs/plugin-sdk.md) for the plugin lifecycle.
