Accessing the API
Here’s the content for the API Documentation: Accessing the API page in the TensenAI Documentation:
API Documentation: Accessing the API
The TensenAI API provides developers with the ability to integrate TensenAI’s AI-powered content creation and optimization features into their own applications, websites, and workflows. Through the API, you can automate content generation, leverage optimization tools, and mint NFTs directly from your own platform.
This page will guide you through the steps for accessing the TensenAI API, including how to get your API key, make your first API request, and start integrating TensenAI into your applications.
1. Introduction to the TensenAI API
The TensenAI API enables you to use the full power of TensenAI’s content creation and optimization tools programmatically. Whether you're building a content management system, automating social media posts, or integrating AI-driven content into an existing application, the API allows you to access the following features:
Content Creation: Generate text, images, audio, and video based on custom prompts.
Content Optimization: Optimize SEO, readability, engagement, and other parameters.
NFT Minting: Mint AI-generated content into NFTs and list them on the marketplace.
Staking: Interact with the staking and rewards system to participate in governance.
2. Getting Started with the TensenAI API
Step 1: Create an Account on TensenAI
To get started with the API, you need to create an account on the TensenAI platform. If you haven’t already, follow these steps:
Visit the TensenAI website and sign up for a free account.
Once registered, log in to your account on the TensenAI platform.
Step 2: Generate Your API Key
To authenticate your API requests, you’ll need an API key. Follow these steps to generate your API key:
After logging in, navigate to the API section from your user profile or dashboard.
Click on Generate API Key to create a new key.
Copy the API key for use in your application. Keep this key secure, as it will allow access to your account's API features.
Step 3: Choose Your Plan
The TensenAI API is available through different subscription plans, including a free plan for basic usage and premium plans for more advanced features:
Free Plan: Limited API calls and access to basic AI tools.
Pro Plan: Full access to all AI features and a higher number of API calls.
Enterprise Plan: Customized plan with API support for large-scale applications and integrations.
Select a plan based on your usage needs, and ensure your API key corresponds to the selected plan.
3. Making Your First API Request
Once you have your API key, you can start making requests to the TensenAI API. Below is a basic example of how to generate text using the API.
API Request Format
All API requests must include the following:
Authorization: Your API key in the header of the request.
Endpoint: The specific API endpoint you are accessing.
Parameters: Data that defines the content you want to generate or optimize (e.g., prompt, length, tone).
Example: Generate Text API Request
curl -X POST https://api.tensenai.com/v1/generate/text \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Write a blog post about the benefits of AI in content creation",
"length": "500",
"tone": "professional"
}'
Explanation of the Request:
Authorization
: Your unique API key. ReplaceYOUR_API_KEY
with the API key you generated.prompt
: The input that instructs the AI on the type of content you want it to create.length
: Specifies the desired length of the content (e.g., 500 words).tone
: Defines the style of the generated content (e.g., professional, casual).
Response Example:
{
"status": "success",
"content": "AI has revolutionized content creation by enabling faster, more efficient, and scalable production. With the power of AI, creators can generate articles, blogs, and social media posts without the time and effort usually required. AI can analyze vast amounts of data and produce coherent, high-quality text, saving creators valuable time and resources."
}
Explanation of the Response:
status
: Indicates whether the request was successful.content
: The generated text based on the prompt provided.
4. Available API Endpoints
Here’s a list of some common API endpoints available in the TensenAI API:
Text Generation
POST /v1/generate/text: Generate text content (e.g., articles, blog posts, captions).
Parameters:
prompt
: The text prompt that defines the content you want to generate.length
: The number of words or characters.tone
: The tone/style of the content (e.g., formal, casual, professional).
Image Generation
POST /v1/generate/image: Generate images based on textual descriptions.
Parameters:
description
: A detailed description of the image you want to create (e.g., "A futuristic city skyline at sunset").style
: The artistic style of the image (e.g., abstract, minimalist, realistic).
Video Generation
POST /v1/generate/video: Generate video content based on a script or description.
Parameters:
script
: A text-based script for the video.style
: The video style (e.g., animation, promotional, explainer).
Audio Generation
POST /v1/generate/audio: Generate voiceovers or music tracks.
Parameters:
text
: The script for voiceovers or instructions for music generation.type
: Type of audio (e.g., voiceover, sound effects, music track).
NFT Minting
POST /v1/mint/nft: Mint a generated content as an NFT.
Parameters:
content_id
: The ID of the generated content.price
: The price of the NFT.title
: The title of the NFT.description
: A description of the NFT.
Staking
POST /v1/stake/tokens: Stake TENS tokens for rewards.
Parameters:
amount
: The number of TENS tokens to stake.duration
: The staking duration (e.g., 30 days, 90 days).
5. Authentication and Security
The TensenAI API uses Bearer token authentication to ensure secure access to the platform. Here’s how to authenticate your API requests:
API Key Authentication
Include the
Authorization
header with your API key in the following format:Authorization: Bearer YOUR_API_KEY
Ensure that your API key is stored securely and not exposed in public-facing code repositories.
Rate Limiting
The API is subject to rate limits depending on the subscription plan you’ve chosen:
Free Plan: Limited API calls per day.
Pro Plan: Higher limits for API calls, suitable for medium-scale applications.
Enterprise Plan: Custom rate limits based on large-scale needs and enterprise integration.
6. Error Handling and Responses
When using the API, it’s important to handle errors appropriately. Below are common API response codes:
200 OK: The request was successful, and the response contains the requested data.
400 Bad Request: The request was malformed or missing required parameters.
401 Unauthorized: Invalid or missing API key.
404 Not Found: The requested resource was not found.
500 Internal Server Error: An error occurred on the server-side while processing the request.
For more detailed error messages, refer to the message
field in the API response.
7. Summary
The TensenAI API is a powerful tool for integrating AI-driven content creation into your applications and workflows. By following this guide, you can quickly get started with the API, create content programmatically, and leverage TensenAI’s advanced features, including text generation, image creation, video production, and NFT minting.
This Accessing the API page in the documentation provides users with a complete guide to setting up, using, and troubleshooting the TensenAI API. It ensures developers can quickly integrate TensenAI’s capabilities into their own projects.
Last updated