Overview

One contract for multiple AI workflows

TokenMarket exposes a unified external API so teams can keep one authentication method, one base URL, and one response style while calling different model capabilities.

OpenAI-style JSON request and response formats
One API key for chat, embeddings, images, audio, rerank, and video generation
Unified billing, quota checks, and request tracing headers

Authentication

Authentication and base URL

Every request uses a Bearer token. Use the official TokenMarket public base URL below.

Base URL

https://cloud.hopegate.ai/api

Required headers

Authorization: Bearer YOUR_TOKENMARKET_API_KEY
Content-Type: application/json

Create API keys from the TokenMarket console, then send them with the Authorization header.

Quick start

Quick start

The fastest way to verify connectivity is to send a minimal chat request.

curl -X POST "https://cloud.hopegate.ai/api/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_TOKENMARKET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "DeepSeek-V4-pro",
    "provider": "dataeyes",
    "messages": [
      { "role": "user", "content": "Reply with only OK." }
    ],
    "stream": false
  }'

Core endpoints

Supported unified endpoints

These endpoints are available through the current public API surface.

PathPurposeNotes
/v1/chat/completionsChat completions and reasoning outputsSupports standard OpenAI-style messages and optional provider selection.
/v1/embeddingsText embeddingsReturns embedding vectors in the provider response format.
/v1/images/generationsText-to-image generationSupports response_format, size, quality, and n when the upstream model allows them.
/v1/audio/speechText-to-speech generationReturns binary audio with TokenMarket request and billing headers.
/v1/rerankDocument rerankingAvailability depends on the upstream model enabled for your account.
/v1/video/generationsVideo generation task creationUsually returns an asynchronous task payload from the upstream provider.

Language examples

Code examples

All samples use the same API key pattern. Replace only YOUR_TOKENMARKET_API_KEY before running them.

Chat completion

cURL

curl -X POST "https://cloud.hopegate.ai/api/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_TOKENMARKET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "DeepSeek-V4-pro",
    "provider": "dataeyes",
    "messages": [
      { "role": "user", "content": "Reply with only OK." }
    ],
    "stream": false
  }'

Embeddings

cURL

curl -X POST "https://cloud.hopegate.ai/api/v1/embeddings" \
  -H "Authorization: Bearer YOUR_TOKENMARKET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-large",
    "provider": "dataeyes",
    "input": "TokenMarket unified API integration"
  }'

Image generation

cURL

curl -X POST "https://cloud.hopegate.ai/api/v1/images/generations" \
  -H "Authorization: Bearer YOUR_TOKENMARKET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "provider": "dataeyes",
    "prompt": "A minimal geometric fox icon on white background",
    "response_format": "url",
    "size": "1024x1024"
  }'

Text to speech

cURL

curl -X POST "https://cloud.hopegate.ai/api/v1/audio/speech" \
  -H "Authorization: Bearer YOUR_TOKENMARKET_API_KEY" \
  -H "Content-Type: application/json" \
  -o speech.mp3 \
  -d '{
    "model": "gpt-4o-mini-tts",
    "provider": "dataeyes",
    "input": "Hello from TokenMarket",
    "voice": "alloy",
    "format": "mp3"
  }'

Rerank

cURL

curl -X POST "https://cloud.hopegate.ai/api/v1/rerank" \
  -H "Authorization: Bearer YOUR_TOKENMARKET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-rerank",
    "provider": "dataeyes",
    "query": "Which document is about TypeScript?",
    "documents": ["TypeScript guide", "Baking bread tutorial", "Marathon training"],
    "top_n": 2
  }'

Video generation

cURL

curl -X POST "https://cloud.hopegate.ai/api/v1/video/generations" \
  -H "Authorization: Bearer YOUR_TOKENMARKET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v1",
    "provider": "dataeyes",
    "prompt": "A paper plane flying over a lake at sunrise",
    "size": "1280x720"
  }'

Error handling

Error handling

TokenMarket normalizes platform and upstream failures into a consistent error envelope.

TypeCodeMeaning
invalid_request_bodyREQUEST_001Request body validation failed.
unauthorizedAUTH_001API key is missing, invalid, or disabled.
provider_errorPROVIDER_001The upstream provider rejected the request or the selected model is unavailable.
timeoutPROVIDER_TIMEOUTThe upstream operation timed out before completion.

FAQ

FAQ

How do I switch languages?

Use the language switcher in the page header. The route stays on the same document path and changes between English and Chinese.

Do I need different APIs for different model categories?

No. TokenMarket keeps separate unified endpoints by operation type, but they all share the same authentication pattern and base URL.

How do I choose a provider?

Add the optional provider field in the request body when you want to target a specific upstream route. If omitted, TokenMarket uses its routing policy or the model's default provider.

Why can a model return PROVIDER_001?

That means the request reached the upstream provider but failed there, for example because the model is not enabled, the provider returned an error, or the transport was interrupted.