Could you clarify which “Kimi K3” you mean and who the provider is? For example:
- Moonshot AI’s Kimi models (OpenAI‑compatible API)?
- A different “Kimi K3” product (e.g., device/service) with its own API?
If it’s an OpenAI‑compatible LLM API (common for Kimi by Moonshot), here’s a provider‑agnostic checklist you can follow while you confirm exact endpoints and model names:
1) Obtain credentials
- Sign up on the provider’s console.
- Create an API key.
- Note the base URL and the exact model name (e.g., something like kimi‑k3 or the provider’s official model ID).
2) Make a chat completion request
- Method: POST
- URL: <API_BASE_URL>/v1/chat/completions (confirm exact path in docs)
- Headers:
- Authorization: Bearer <YOUR_API_KEY>
- Content-Type: application/json
- JSON body (example):
{
"model": "<MODEL_NAME>",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, Kimi K3!"}
],
"stream": false
}
- Response: JSON with choices[0].message.content containing the assistant reply.
3) Streaming (if supported)
- Same endpoint and headers.
- Set "stream": true in the JSON body.
- Read Server‑Sent Events (SSE) chunks until [DONE].
4) Error handling
- 401/403: invalid or missing API key.
- 429: rate limited; implement retries with backoff.
- 5xx: transient server errors; retry safely.
5) Safety and usage tips
- Keep your API key secret (use server‑side calls or a secure proxy).
- Set request‑level parameters (temperature, top_p, max_tokens) per your use case.
- Log request IDs from response headers (if provided) for support.
6) SDKs
- If the provider offers official SDKs (JavaScript/Python/Go, etc.), install the package, set the API key via environment variable, and call a ChatCompletion method with the same model and messages structure.
If you can share:
- The provider/documentation link
- The exact model ID and base URL
- Your preferred language (Python/JS/etc.)
…I can give you a drop‑in example tailored to the actual Kimi K3 API.
Apprenez à utiliser la Kimi K3 API via CometAPI. Inclut la configuration, la tarification, le streaming, l’effort de raisonnement, l’entrée visuelle, etc.