Get API key

cursorapikey.com/Guide

How to Use GitHub Copilot API Key with Cursor API

Using a GitHub Copilot API key with the Cursor API allows you to decouple your billing and access a dedicated uncensored coding model for AI agents. This guide explains the technical steps to reconfigure your environment, switch base URLs, and handle streaming responses while maintaining compatibility with standard OpenAI SDKs.

Updated

Key points

  • GitHub Copilot API keys are tied to Microsoft's infrastructure, whereas the Cursor API provides an independent, uncensored model endpoint.
  • You can switch from Copilot to our API by updating the base_url in your coding agent's configuration without changing the core SDK logic.
  • Streaming responses and tool calling work identically if you use the standard OpenAI-compatible chat-completions endpoint.
  • Monitoring usage is straightforward via the dashboard, but you must manage token costs separately from your GitHub subscription.

Understanding API Key Compatibility

When developers refer to a github copilot api key, they are typically referring to a token generated within the Microsoft GitHub ecosystem. This key authenticates requests to Microsoft's servers, which run models like GPT-4o or specialized variants optimized for code. While these models are powerful, they come with specific content filters and rate limits tied to your Microsoft account.

In contrast, the Cursor API operates as an independent service. It does not rely on Microsoft's infrastructure. Instead, it serves a single, open-weight large language model optimized for coding contexts. This model is designed to answer without content refusals for lawful adult use, making it a distinct alternative for developers who find standard filters restrictive.

Understanding this distinction is crucial. Your existing GitHub Copilot API key will not work with the Cursor API endpoint. You need a separate key generated from your account on cursorapikey.com. However, the underlying protocol remains the same, meaning your code doesn't need to change significantly.

Configuring Your Environment

To use the Cursor API, you first need to generate a key. Sign up on the Get API key page with just an email and password. No credit card is needed for the initial trial credit. Once registered, your key is displayed immediately. Store this key securely in your environment variables, typically as OPENAI_API_KEY or a custom variable depending on your agent's requirements.

Most coding agents, including Cursor and similar tools, rely on the OpenAI SDK standard. This means you don't need a custom library. You simply need to point your SDK to the correct base URL. The base URL for the Cursor API is https://api.cursorapikey.com/v1. This endpoint is fully OpenAI-compatible, supporting the same request structures you are already familiar with.

Ensure your environment is configured to send requests to this new base URL. The model ID you must specify in your requests is uncensored. This tells the API which specific model to invoke. It is an open-weight model run on our own GPU servers, distinct from GPT, Claude, or Gemini.

Switching Base URLs

Switching from a github copilot api key to the Cursor API primarily involves changing the base URL in your client configuration. If you are using the official OpenAI Python or Node.js SDKs, this is a one-line change. For example, in Python, you would initialize the client with the new base URL and your new API key.

This change redirects your requests from Microsoft's servers to our infrastructure. The benefits include access to a 100,000 token context window and a model tuned for fewer refusals. You can verify the connection by checking the /v1/models endpoint, which should return the available models, including uncensored.

Trade-off: While the syntax is identical, you are now paying per token rather than through a Microsoft subscription. Our pricing is transparent: $0.25 per 1M input tokens and $1.00 per 1M output tokens. There are no monthly fees, just pay-as-you-go credit that never expires. This model is ideal for variable workloads where you don't want to commit to a monthly seat cost.

Testing Your Connection

Before integrating the API into your main workflow, it is essential to verify that your environment can communicate with the Cursor API. You can do this with a simple cURL command or a short script. This test ensures your key is valid and the base URL is correct.

Example cURL request:

Send a POST request to https://api.cursorapikey.com/v1/chat/completions with the model set to uncensored. Include a simple prompt in the messages array. A successful response will return a completion in the choices[0].message.content field.

If you receive a 401 error, your API key is incorrect. If you get a 429 error, you have exceeded the rate limit of 300 requests per minute per key. You can regenerate your key at any time to invalidate the old one. This test confirms that the basic text-in, text-out functionality is working as expected.

Handling Streaming Responses

For coding agents, streaming responses are critical for providing a smooth user experience. The Cursor API supports Server-Sent Events (SSE) for streaming. This allows you to receive tokens as they are generated, rather than waiting for the full response.

When using the OpenAI SDK, you can enable streaming by setting the stream parameter to true. The SDK will yield chunks of data as they arrive. This is particularly useful for long code generations, where you want to display progress to the user or feed tokens into a live editor.

Be aware that streaming does not change the underlying model or its capabilities. It is purely a delivery mechanism. The uncensored model will still adhere to the 100,000 token context window and the same pricing structure. Streaming is a client-side feature that improves perceived latency without affecting the model's behavior.

Tool Calling Integration

Modern AI coding assistants rely heavily on tool calling (function calling) to interact with the outside world, such as running shell commands or accessing files. The Cursor API supports this via the standard OpenAI-compatible format.

You can define tools in your request using the tools parameter. The model will respond with a tool_calls array if it determines a tool should be used. Your application must then execute the tool and send the results back to the API in a subsequent message.

This process is identical to how you would use a github copilot api key with Microsoft's models. The advantage here is consistency. If you have existing code for tool calling, you can likely reuse it with minimal adjustments. Just ensure your tool definitions match the expected schema for the uncensored model.

Monitoring Usage

Since you are paying per token, monitoring your usage is important to avoid unexpected costs. The Cursor API provides a dashboard where you can view your credit balance and usage history. You can see how many tokens you have consumed and how much credit remains.

Key limits to watch:

  • Rate limit: 300 requests per minute per key.
  • Request body size: Maximum 8 MB per request.
  • Context window: 100,000 tokens total (input + output).

If you exceed the rate limit, you will receive a 429 error. You can monitor your usage in real-time to ensure you stay within these bounds. Additionally, you can regenerate your API key if you suspect it has been compromised, which immediately invalidates the old key.

Troubleshooting Common Issues

Even with a robust API, issues can arise. Here are some common problems and their solutions.

401 Unauthorized: Check your API key. Ensure it is copied correctly and has no leading or trailing spaces. If you regenerated your key, make sure you are using the new one.

429 Too Many Requests: You have exceeded the 300 requests per minute limit. Implement exponential backoff in your client or reduce the frequency of your requests.

400 Bad Request: This usually indicates a malformed JSON payload or missing required fields. Ensure your messages array is correctly formatted and includes the role and content fields. Also, verify that the model name is exactly uncensored.

Content Blocking: While the model is uncensored, it does block sexual content involving minors. If your request is blocked, it may be due to this specific hard limit.

01

Questions and answers

Can I use my GitHub Copilot API key with the Cursor API?

No, the GitHub Copilot API key is specific to Microsoft's infrastructure. To use the Cursor API, you need to generate a separate key from your account on cursorapikey.com. However, the API protocol is the same, so your code can likely remain unchanged.

What is the context window for the uncensored model?

The context window is 100,000 tokens, covering both the prompt and the completion. This allows for handling large codebases or extensive conversations within a single request.

Does the Cursor API support streaming?

Yes, the API supports streaming via Server-Sent Events (SSE). You can use the standard OpenAI SDKs with the <code>stream</code> parameter enabled to receive tokens as they are generated.

How much does the Cursor API cost?

The pricing is $0.25 per 1M input tokens and $1.00 per 1M output tokens. There are no monthly fees, just pay-as-you-go prepaid credit. You can start with a $0.50 trial credit for new accounts.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.