Add Token Market as an OpenAI-compatible provider with authenticated model discovery
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Summary
Add Token Market as a first-class OpenAI-compatible provider in JCode, with authenticated model discovery from GET /v1/models.
Token Market is a multi-provider model gateway. Its OpenAI-compatible API base is:
https://api.tokensmarket.ai/v1
I am affiliated with Token Market and can help verify the integration and provide test credentials privately if a maintainer wants to validate the live API.
Why this fits JCode
JCode already has a reusable OpenAiCompatibleProfile path for hosted gateways such as OpenRouter and Conifer. Token Market can use that existing transport rather than adding a provider-specific runtime.
A built-in profile would improve the current manual openai-compatible setup by providing:
- a discoverable
tokenmarketCLI/provider choice - the correct API base and API-key environment variable
- authenticated model discovery
- a stable setup/documentation link
- API-key redaction and external-auth import behavior consistent with other providers
Proposed integration
Add a profile equivalent to:
OpenAiCompatibleProfile {
id: "tokenmarket",
display_name: "Token Market",
api_base: "https://api.tokensmarket.ai/v1",
api_key_env: "TOKENMARKET_API_KEY",
env_file: "tokenmarket.env",
setup_url: "https://www.tokensmarket.ai/docs/api-examples/api-key",
default_model: None,
requires_api_key: true,
}
Suggested alias: token-market.
The live model catalog endpoint requires the same Bearer API key:
GET https://api.tokensmarket.ai/v1/models
Authorization: Bearer $TOKENMARKET_API_KEY
The response follows the OpenAI models-list shape (data[].id). Because the available catalog changes, I suggest using live discovery as the source of truth. A small static fallback can be added if JCode requires offline model selection, but pricing or context metadata should not be guessed when it is absent from the endpoint.
Chat requests use the standard OpenAI-compatible endpoint:
POST https://api.tokensmarket.ai/v1/chat/completions
Authorization: Bearer $TOKENMARKET_API_KEY
Content-Type: application/json
Streaming and tool calls use the ordinary OpenAI-compatible request/response format. Some reasoning models also return reasoning_content; provider-specific reasoning controls can remain out of the initial integration unless JCode has a generic way to pass them safely.
Expected implementation surface
Following the existing OpenAI-compatible provider pattern, this would likely touch:
crates/jcode-provider-metadata/src/catalog.rs- login-provider metadata and profile registration
src/cli/provider_init.rsand provider listing/help text- API-key import/redaction mappings
- static fallback catalog only if required
- focused tests for profile lookup, CLI selection, authenticated
/modelsdiscovery, and secret redaction
No new provider runtime should be necessary.
Acceptance criteria
jcode --provider tokenmarketis recognized- login/setup stores
TOKENMARKET_API_KEYintokenmarket.env - model discovery calls
/v1/modelswith a Bearer token - discovered chat-capable model IDs are selectable
- API keys are redacted from diagnostics/messages
- existing OpenAI-compatible provider tests continue to pass
References
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with crates/jcode-provider-metadata/src/catalog.rs and the existing OpenAiCompatibleProfile path, then trace login-provider registration and src/cli/provider_init.rs. Check the provider listing, API-key import/redaction mappings, and focused provider tests. Done means tokenmarket is selectable, stores TOKENMARKET_API_KEY in tokenmarket.env, discovers models through authenticated /v1/models, and preserves secret redaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100