EN ▾
Get API key

Integrating ltxapi.cc with Your Stack

Connecting an uncensored text API to your application requires careful attention to authentication and token management. This guide walks you through the essential steps to integrate our service into your stack, ensuring smooth communication between your code and the model.

Developer workspace with glowing blue code interface and chat bubble on dark background

Understanding the API Structure

Before writing code, it is essential to understand the structure of our hosted service. We provide an OpenAI-compatible chat-completions API that serves a single uncensored open-weight text model. The model identifier you must send is uncensored. This simplifies integration because you do not need to manage model routing or select from multiple variants. The API follows standard conventions, making it familiar to developers who have worked with similar services before.

The base URL for all requests is https://api.ltxapi.cc/v1. You will interact with three primary endpoints. The POST /v1/chat/completions endpoint handles standard chat interactions. The POST /v1/responses endpoint offers an alternative response format. The GET /v1/models endpoint allows you to verify available models, though only one is active. Keeping these endpoints in mind helps you structure your HTTP client correctly.

Our API is designed for text-in, text-out operations. It does not support embeddings, image generation, audio processing, or video generation. There is no OCR capability, no fine-tuning options, and no model routing features. This focused approach means your integration will be lightweight and efficient. You only need to handle text data, which reduces the complexity of your codebase significantly.

When integrating, ensure your HTTP client is configured to handle JSON payloads and responses. The API expects standard headers for authentication and content type. By sticking to the core text capabilities, you avoid unnecessary overhead. This clarity allows you to build reliable applications without worrying about unsupported features. The simplicity of the API structure is a key advantage for rapid development.

Authentication and Security

Authentication is the first step in any integration. You can sign up using Google or an email and password combination. Upon signup, your API key is shown immediately, allowing you to start testing right away. This key is required for all requests to the API. You must include it in the authorization header of your HTTP requests. Keeping this key secure is important for preventing unauthorized usage of your prepaid credits.

The API uses standard bearer token authentication. You should store your API key in environment variables rather than hardcoding it in your source files. This practice prevents accidental exposure in version control systems. When making requests, ensure the header is formatted correctly. Most HTTP libraries have built-in support for bearer tokens, which simplifies this process.

If your key is invalid, the API returns a 401 error. This indicates that the key is missing, malformed, or not recognized. If you run out of credit, you will receive a 402 error. This means you need to top up your account before making further requests. Understanding these error codes helps you implement proper error handling in your application.

Rate limits are enforced at 300 requests per minute per key. If you exceed this limit, the API returns a 429 error. You should implement retry logic with exponential backoff in your code to handle these situations gracefully. Monitoring your request rate ensures a smooth user experience. Proper authentication and error handling form the foundation of a reliable integration.

SDK Configuration and Parameters

Our API supports several parameters that allow you to fine-tune the model's behavior. You can set the temperature to control creativity, top_p for nucleus sampling, and stop sequences to halt generation. The seed parameter ensures reproducible results, which is useful for debugging. These parameters are passed in the request body. Configuring them correctly allows you to tailor the output to your specific needs.

Streaming is supported over Server-Sent Events (SSE). This feature is essential for applications that require real-time responses. The usage information is included in the last chunk of the stream. This allows you to track token consumption as the response is generated. Implementing streaming requires handling partial responses and updating the UI incrementally. This creates a more responsive and engaging user experience.

Function calling, also known as tools, is supported. This allows the model to generate structured data that your application can execute. You define the tools in your request, and the model returns calls to these tools. This is powerful for creating agents that can interact with external systems. JSON mode is also available, ensuring the output is valid JSON. This is useful for parsing responses programmatically.

Penalties can be applied to discourage certain tokens. This helps in controlling the tone and style of the output. By adjusting these parameters, you can optimize the model for your use case. The flexibility of the API allows for a wide range of applications. Proper SDK configuration ensures that you can use these features effectively. Always refer to the documentation for the latest parameter details.

Token Management and Pricing

Understanding token usage is critical for managing costs. The context window is 100,000 tokens, which includes both the prompt and the completion. This large window allows for extensive conversations and document processing. However, it is important to monitor token usage to avoid unexpected charges. The API charges $0.15 per 1M input tokens and $0.50 per 1M output tokens.

Credit is prepaid and charged by real token usage. Errors and refusals are free, which protects you from unnecessary costs. There is no subscription or monthly fee, giving you flexibility. Paid credit never expires, so you can use it whenever you need. This model is ideal for projects with variable usage patterns. You only pay for what you use.

Top-ups can be made using crypto only. We accept USDT on TRC20 or USDC on Base. The minimum amount is $20, and the maximum is $500. You can top up any whole amount within this range. Bonus credit is available for top-ups of $50 or more, ranging from +5% to +15%. This incentivizes larger top-ups. No cards, PayPal, or bank transfers are accepted.

Every new account receives $0.50 of trial credit, no card needed. This allows you to test the API without immediate financial commitment. When estimating costs, use the formula: (tokens divided by 1,000,000) times the per-million price. Avoid calculating exact dollar totals in your code. Focus on token counts to manage your budget effectively. This approach ensures accurate cost tracking.

Error Handling and Troubleshooting

Effective error handling is important for a reliable integration. The API returns specific error codes to help you diagnose issues. A 401 error indicates an invalid key. A 402 error means you have no credit. A 429 error signals that you have hit the rate limit. These codes are standard and should be handled appropriately in your code.

When encountering a 429 error, implement exponential backoff. This involves waiting longer between retries as the number of retries increases. This prevents overwhelming the API and helps you stay within rate limits. Monitoring your request rate is essential. You can also implement a queue to manage requests during peak times. This ensures a smooth user experience even under high load.

Content limits are enforced, particularly regarding sexual content involving minors. Such requests are refused, and the API returns an appropriate error. This is a hard limit that cannot be bypassed. Understanding these limits helps you design your application to avoid unnecessary refusals. You can implement pre-filtering in your application to check for sensitive content before sending requests.

Logging errors and monitoring performance helps identify issues early. Use structured logging to capture error codes, messages, and timestamps. This data is valuable for debugging and optimization. Regularly review your error logs to identify patterns. By proactively addressing issues, you can maintain a reliable integration. Proper error handling ensures that your application remains stable and responsive.

When Our API Is Not the Right Choice

While our API is powerful for text generation, it may not be the right choice for all projects. If you need image generation, audio processing, or video creation, this service will not meet your needs. The API is text-only, so any multimodal requirements must be handled by other services. This is an important consideration when choosing an API for your stack.

If you require embeddings for semantic search, our API does not support this feature. You would need to use a separate embedding service. Similarly, if you need OCR for document processing, this API cannot handle it. These limitations mean that your integration might require multiple APIs to achieve your goals. This can increase complexity and cost.

Fine-tuning is not available on our API. If you need to train the model on your specific data, you would need a different service. Model routing is also absent, meaning you cannot switch between different models dynamically. These features are common in larger platforms but are not part of our offering. Understanding these limitations helps you make an informed decision.

If you need an SLA guarantee or certifications like SOC2 or HIPAA, our API does not provide these. We are an independent service without these formal guarantees. For applications requiring strict compliance, you might need a more established provider. However, for uncensored text generation, our API offers a unique value proposition. Always evaluate your specific needs before integrating.

Best Practices for Integration

Following best practices ensures a smooth and efficient integration. Start by setting up your environment variables for the API key and base URL. This keeps your credentials secure and makes configuration easy. Use a dedicated configuration file for your project. This approach simplifies deployment and management. Always keep your API key out of version control.

Implement comprehensive error handling and logging. This helps you diagnose issues quickly and improve reliability. Use structured logging to capture detailed information about each request. Monitor your token usage and rate limits closely. This prevents unexpected costs and service interruptions. Regularly review your logs to identify trends and optimize performance.

Test your integration thoroughly before deploying to production. Use the trial credit to experiment with different parameters and configurations. This helps you understand the API's behavior and limitations. Implement automated tests to ensure your code handles edge cases correctly. This reduces the risk of bugs in production. Thorough testing is key to a successful integration.

Keep your integration up to date with the latest API changes. The API may evolve, so staying informed is important. Subscribe to announcements or check the documentation regularly. This ensures you can adapt to new features or changes promptly. By following these best practices, you can build a reliable and scalable integration. Continuous improvement leads to a better user experience.

Frequently asked questions

How do I get an API key?

You can sign up using Google or an email and password. Your API key is shown immediately after signup, allowing you to start using the service right away without any initial cost.

What payment methods are accepted?

We accept only crypto payments. You can top up using USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. Credit cards and PayPal are not accepted.

Does the API support image generation?

No, the API is text-only. It does not support image, audio, or video generation. If you need multimodal capabilities, you will need to integrate additional services alongside our text API.

What happens if I run out of credit?

You will receive a 402 error when trying to make a request. You can top up your account using crypto to restore your balance. Errors and refusals do not consume credit, so you only pay for successful token usage.