<!-- Generated from public website sources; do not edit this file. -->

# Your first API call
Use cURL, Python or Node.js to make a Chat Completions request once DeepSeekSub.com API access is available. The endpoint, model ID and key issuance are not yet verified.

## Get your connection details
Keep these three values from the same provider. A subscription key cannot automatically be used with the official DeepSeek endpoint.

| Setting | What to use |
| --- | --- |
| API key | A key issued by your API provider |
| Base URL | The provider's OpenAI-compatible API base, including any required version prefix |
| Model | The exact model ID enabled for your account |

DeepSeekSub.com payment and API access are being integrated. Its base URL, supported model ID and API-key issuance are not yet published; no request below has been verified against its production service. The table and examples are illustrative, not a working DeepSeekSub.com connection. Replace placeholders only after the service provides confirmed values.

## Set environment variables
### macOS / Linux
Set these in the terminal where you will run your code. Include a version prefix such as `/v1` only if your provider requires it; omit the final slash.

```sh
export CODING_PLAN_API_KEY="your-api-key"
export CODING_PLAN_BASE_URL="https://your-provider.example/v1"
export CODING_PLAN_MODEL="your-model-id"
```

### Windows PowerShell
```powershell
$env:CODING_PLAN_API_KEY = "your-api-key"
$env:CODING_PLAN_BASE_URL = "https://your-provider.example/v1"
$env:CODING_PLAN_MODEL = "your-model-id"
```

Environment variables apply to the current terminal session. Run the Python or Node.js example below in that same terminal on either platform. The cURL example uses macOS / Linux shell syntax.

## Send a request
Choose a language. Python requires `python -m pip install openai`; Node.js requires `npm install openai` and an `.mjs` file. These examples send one short request, which may consume allowance.

```sh
curl --fail-with-body "$CODING_PLAN_BASE_URL/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $CODING_PLAN_API_KEY" \
  -d "{\"model\":\"$CODING_PLAN_MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"Say hello in one sentence.\"}],\"stream\":false}"
```

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["CODING_PLAN_API_KEY"],
    base_url=os.environ["CODING_PLAN_BASE_URL"],
)
response = client.chat.completions.create(
    model=os.environ["CODING_PLAN_MODEL"],
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
    stream=False,
)
print(response.choices[0].message.content)
```

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.CODING_PLAN_API_KEY,
  baseURL: process.env.CODING_PLAN_BASE_URL,
});
const response = await client.chat.completions.create({
  model: process.env.CODING_PLAN_MODEL,
  messages: [{ role: "user", content: "Say hello in one sentence." }],
  stream: false,
});
console.log(response.choices[0].message.content);
```

## Read the response
The assistant's answer is in `choices[0].message.content`. Below is an illustrative excerpt; actual text and token counts vary.

```json
{
  "choices": [{
    "message": { "role": "assistant", "content": "Hello! How can I help?" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 12, "completion_tokens": 8, "total_tokens": 20 }
}
```

When service is available, check the returned usage fields and your account ledger against the applicable billing rules; DeepSeekSub.com metering and quota behavior are not yet verified. Streaming and tool calls also require separate service tests.

If the request fails, use the HTTP status and response message with the [error guide](https://deepseeksub.com/docs/error-codes/index.md). Check the endpoint path before changing your key.

## Keep building
- [Stream a response](https://deepseeksub.com/docs/streaming/index.md) to display text as it arrives.
- [Continue a conversation](https://deepseeksub.com/docs/multi-turn/index.md) by sending message history.
- [Understand token usage](https://deepseeksub.com/docs/token-usage/index.md) before scaling up requests.
- Set up [Claude Code](https://deepseeksub.com/docs/claude-code/index.md), [Codex](https://deepseeksub.com/docs/codex/index.md), or [OpenCode](https://deepseeksub.com/docs/opencode/index.md).

Official provider keys and connection settings belong to the official service. See [models and API compatibility](https://deepseeksub.com/docs/models/index.md) for the distinction.

---

HTML source: [Your first API call — DeepSeek Subscription Tutorials](https://deepseeksub.com/docs/quickstart/)
