Notice: Undefined index: user_id in /home/u391725163/domains/lannetech.com/public_html/endpoint/pages/api-documentation.php on line 38

Notice: Trying to access array offset on value of type bool in /home/u391725163/domains/lannetech.com/public_html/endpoint/includes/functions.php on line 65
llama-4-scout

llama-4-scout

Language

Open-source large language model for general text generation and understanding.

0 credits

Overview

Open-source large language model for general text generation and understanding.

Fast Response

Average response time < 200ms

High Reliability

99.9% uptime guarantee

Secure

End-to-end encrypted

API Version

You're viewing documentation for version v1 of the API. Please ensure you're using the correct endpoint in your requests.

Authentication

All API calls must be authenticated using your API key. Include your API key in the Authorization header as a Bearer token.

Example Authentication

curl -X POST "https://api.lannetech.com/v1/generate-text" \
    -H "Authorization: Bearer 8eb8e627ddda785eb75add57dda1839a6b4956cad05aa2dcee6024239d4c2b97" \
    -H "Content-Type: application/json"

Security Best Practices

Keep your API key secure and never share it in public repositories or client-side code. You can regenerate your API key from the dashboard if needed.

Endpoints

POST /v1/generate-text

Base URL

https://api.lannetech.com

All API requests should be made to this base URL followed by the endpoint path.

HTTPS Required

All API requests must use HTTPS. Requests over plain HTTP will fail.

Request Format

Send data as JSON in the request body with Content-Type: application/json.

Parameters

Send the following parameters in the request body as JSON.

Parameter Type Required Description
modelstringYesModel identifier to use for this request
messagesarrayYesParameter messages
max_tokensintegerYesMaximum number of tokens to generate
temperaturedoubleYesControls generation creativity (0.0 to 1.0)

Parameter Example

{
    "model": "llama-4-scout",
    "messages": [
        {
            "role": "user",
            "content": "Write a short story about AI"
        }
    ],
    "max_tokens": 100,
    "temperature": 0.7
}

Asynchronous Generation

This API uses an asynchronous generation process. This means the generation happens in two steps:

1 Initial Request

First, make a POST request with your generation parameters. You'll receive a request_id in response.

// Response from initial request
{
    "text": "your prompt",
    "model": "riffusion",
    "request_id": "11aeb1db-1860-4550-b221-7cbfa1169732",
    "status": "pending",
    "created": 1745023903
}

2 Status Check

Then, use the request_id to check the generation status until it's complete.

// Response from status check
{
    "model": "riffusion",
    "request_id": "11aeb1db-1860-4550-b221-7cbfa1169732",
    "status": "success",
    "audio_url": "https://storage.googleapis.com/...",
    "created": 1745023903
}

Status Check Request

To check the status of your generation, make a POST request to the same endpoint with only the request_id:

curl -X POST "https://api.lannetech.com/v1/generate-text" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "request_id": "11aeb1db-1860-4550-b221-7cbfa1169732"
}'

Automatically Wait for Results

For audio models like Riffusion, you can use the wait_for_result parameter to automatically wait until the generation is complete:

curl -X POST "https://api.lannetech.com/v1/generate-text" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "prompt": "A calm and relaxing piano track with soft melodies",
    "model": "riffusion",
    "wait_for_result": true
}'

How It Works

  • When wait_for_result is set to true, the API waits up to 60 seconds for the generation to complete
  • If the generation completes within this time frame, you'll receive the final result with the audio URL directly
  • If the generation takes longer, the request will time out and you'll need to check the status as usual
  • This option is particularly useful for integrations where you prefer a single request
Example response with wait_for_result
{
    "model": "riffusion",
    "request_id": "c9d0596caafdef1a72fa596b464eb1b7",
    "status": "complete",
    "audio_url": "https://kieaifiles.erweima.ai/ZmE3ZjEyNWUtNzEwMS00YjFiLTlmYWQtMzkzMmMyYzZiMDU4.mp3",
    "data": {
        "task_id": "c9d0596caafdef1a72fa596b464eb1b7",
        "status": "complete",
        "callback_type": "first",
        "data": [
            {
                "id": "8551****662c",
                "audio_url": "https://kieaifiles.erweima.ai/ZmE3ZjEyNWUtNzEwMS00YjFiLTlmYWQtMzkzMmMyYzZiMDU4.mp3",
                "stream_audio_url": "https://example.cn/****",
                "prompt": "A calm and relaxing piano track with soft melodies",
                "model_name": "chirp-v3-5",
                "duration": 198.44
            }
        ],
        "received_at": "2025-01-01 00:00:00"
    },
    "created": 1746291951
}

Status Values

Status Description
pending The generation is still in progress
success Generation completed successfully, result is available
complete Generation completed successfully (equivalent to success), result is available
failed Generation failed, check error message

Best Practices

  • Poll the status endpoint at reasonable intervals (e.g., every 2-3 seconds)
  • Implement exponential backoff to avoid rate limiting
  • Set a maximum number of retries or timeout duration
  • Store the request_id if you need to check the status later

Code Examples

Below are examples showing how to use this API in different programming languages.

Request
curl -X POST "https://api.lannetech.com/v1/generate-text" \
    -H "Authorization: Bearer 8eb8e627ddda785eb75add57dda1839a6b4956cad05aa2dcee6024239d4c2b97" \
    -H "Content-Type: application/json" \
    -d '{
    "model": "llama-4-scout",
    "messages": [
        {
            "role": "user",
            "content": "Write a short story about AI"
        }
    ],
    "max_tokens": 100,
    "temperature": 0.7
}'

Notes

  • This command can be run directly from your terminal
  • Make sure to escape special characters in your parameters
  • For Windows command prompt, use double quotes instead of single quotes for the JSON data

Response Format

The API returns responses in JSON format. Below is an example of a successful response.

Response
{
    "text": "Generated text response",
    "usage": {
        "prompt_tokens": 10,
        "completion_tokens": 100,
        "total_tokens": 110
    }
}

Response Fields

  • text - Generated or processed text
  • usage - Token usage information for billing purposes

Handling Responses

  • Always check the HTTP status code before processing the response
  • Parse the JSON response to extract the data
  • Handle any error messages in the response
  • Implement retry logic for temporary failures (e.g., rate limits)

HTTP Status Codes

The API uses standard HTTP status codes to indicate the success or failure of requests.

Code Status Description
200 OK The request was successful. The response contains the requested data.
400 Bad Request The request was invalid. Check the request parameters and format.
401 Unauthorized Authentication failed. Check your API key.
402 Payment Required Insufficient credits for this operation. Please add more credits to your account.
429 Too Many Requests Rate limit exceeded. Slow down your request rate.
500 Server Error An error occurred on the server. Try again later or contact support if the issue persists.
504 Gateway Timeout The operation took too long to complete. Try again with simplified parameters.

Rate Limits

To ensure fair usage and service stability, API requests are subject to rate limiting.

20
Requests per minute
1,000
Requests per day
60
Max request duration (s)

Rate Limit Headers

API responses include headers to help you track your rate limit usage:

  • X-RateLimit-Limit: Maximum requests allowed in the current period
  • X-RateLimit-Remaining: Number of requests remaining in the current period
  • X-RateLimit-Reset: Time (in seconds) until the limit resets

Need Help?

If you have questions or run into issues, our developer support team is ready to help.