getting-started.mdx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ---
  2. title: "Getting Started"
  3. sidebarTitle: "Getting Started"
  4. description: "Create an API key and make your first request to the Cline API in under a minute."
  5. ---
  6. This guide walks you through creating an API key and making your first Chat Completions request.
  7. ## Prerequisites
  8. - A Cline account at [app.cline.bot](https://app.cline.bot)
  9. - `curl` or any HTTP client (Python, Node.js, etc.)
  10. ## Create an API Key
  11. <Steps>
  12. <Step title="Sign in to app.cline.bot">
  13. Go to [app.cline.bot](https://app.cline.bot) and sign in with your account.
  14. </Step>
  15. <Step title="Navigate to API Keys">
  16. Open **Settings** and select **API Keys**.
  17. </Step>
  18. <Step title="Create a new key">
  19. Click **Create API Key**. Copy the key immediately. You will not be able to see it again after leaving this page.
  20. </Step>
  21. </Steps>
  22. <Warning>
  23. Treat your API key like a password. Do not commit it to version control or share it publicly.
  24. </Warning>
  25. ## Make Your First Request
  26. Replace `YOUR_API_KEY` with the key you just created:
  27. ```bash
  28. curl -X POST https://api.cline.bot/api/v1/chat/completions \
  29. -H "Authorization: Bearer YOUR_API_KEY" \
  30. -H "Content-Type: application/json" \
  31. -d '{
  32. "model": "anthropic/claude-sonnet-4-6",
  33. "messages": [
  34. {"role": "user", "content": "What is the capital of France?"}
  35. ],
  36. "stream": false
  37. }'
  38. ```
  39. ## Verify the Response
  40. You should get a JSON response like this:
  41. ```json
  42. {
  43. "id": "gen-abc123",
  44. "model": "anthropic/claude-sonnet-4-6",
  45. "choices": [
  46. {
  47. "message": {
  48. "role": "assistant",
  49. "content": "The capital of France is Paris."
  50. },
  51. "finish_reason": "stop",
  52. "index": 0
  53. }
  54. ],
  55. "usage": {
  56. "prompt_tokens": 14,
  57. "completion_tokens": 8
  58. }
  59. }
  60. ```
  61. The `choices[0].message.content` field contains the model's reply. The `usage` field shows how many tokens were consumed.
  62. ## Try Streaming
  63. For real-time output, set `stream: true`. The response arrives as Server-Sent Events:
  64. ```bash
  65. curl -X POST https://api.cline.bot/api/v1/chat/completions \
  66. -H "Authorization: Bearer YOUR_API_KEY" \
  67. -H "Content-Type: application/json" \
  68. -d '{
  69. "model": "anthropic/claude-sonnet-4-6",
  70. "messages": [
  71. {"role": "user", "content": "Write a haiku about programming."}
  72. ],
  73. "stream": true
  74. }'
  75. ```
  76. Each chunk arrives as a `data:` line. The stream ends with `data: [DONE]`.
  77. ## Try a Free Model
  78. To test without spending credits, use one of the [free models](/api/models#free-models):
  79. ```bash
  80. curl -X POST https://api.cline.bot/api/v1/chat/completions \
  81. -H "Authorization: Bearer YOUR_API_KEY" \
  82. -H "Content-Type: application/json" \
  83. -d '{
  84. "model": "minimax/minimax-m2.5",
  85. "messages": [
  86. {"role": "user", "content": "Hello! What can you help me with?"}
  87. ],
  88. "stream": false
  89. }'
  90. ```
  91. ## Troubleshooting
  92. | Problem | Solution |
  93. |---------|----------|
  94. | `401 Unauthorized` | Check that your API key is correct and included in the `Authorization` header |
  95. | `402 Payment Required` | Your account has insufficient credits. Add credits at [app.cline.bot](https://app.cline.bot) |
  96. | Empty response | Make sure `messages` is a non-empty array with at least one user message |
  97. | Connection timeout | Verify your network can reach `api.cline.bot`. Check proxy settings if on a corporate network |
  98. ## Next Steps
  99. <CardGroup cols={2}>
  100. <Card title="Authentication" icon="key" href="/api/authentication">
  101. Learn about API keys, token scoping, and security practices.
  102. </Card>
  103. <Card title="Chat Completions" icon="message" href="/api/chat-completions">
  104. Full endpoint reference with all parameters and options.
  105. </Card>
  106. <Card title="Models" icon="brain" href="/api/models">
  107. Browse available models and find the right one for your use case.
  108. </Card>
  109. <Card title="SDK Examples" icon="code" href="/api/sdk-examples">
  110. Use the API from Python, Node.js, or the Cline CLI.
  111. </Card>
  112. </CardGroup>