Llama 3.1 8b Serverless API
Meta developed and released the Meta Llama 3 family of large language models (LLMs), a collection of pretrained and instruction tuned generative text models in 8 and 70B sizes. The Llama 3 instruction tuned models are optimized for dialogue use cases and outperform many of the available open source chat models on common industry benchmarks.
API Format: OpenAI GPT (Standard Format)
This model uses OpenAI-compatible request/response format.
POST /v2/llama-v3p1-8b-instruct · submit + poll 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5payload = {
6 "messages": [
7 {
8 "role": "user",
9 "content": "What is the capital of France?"
10 }
11 ]
12}
13
14# Async chat (v2): submit to the queue, block until COMPLETED.
15reply = segmind.chat("llama-v3p1-8b-instruct", **payload)
16print(reply.text)
17
18# --- Or get a handle (track request_id, control the poll cadence) ---
19job = segmind.submit_chat("llama-v3p1-8b-instruct", **payload)
20print(job.request_id) # available immediately
21reply = job.wait(timeout=600)
22print(reply.text) 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5payload = {
6 "messages": [
7 {
8 "role": "user",
9 "content": "What is the capital of France?"
10 }
11 ]
12}
13
14# Async chat (v2): submit to the queue, block until COMPLETED.
15reply = segmind.chat("llama-v3p1-8b-instruct", **payload)
16print(reply.text)
17
18# --- Or get a handle (track request_id, control the poll cadence) ---
19job = segmind.submit_chat("llama-v3p1-8b-instruct", **payload)
20print(job.request_id) # available immediately
21reply = job.wait(timeout=600)
22print(reply.text)API Endpoint
POST https://api.segmind.com/v1/llama-v3p1-8b-instructParameters
messagesrequiredobject[]Array of message objects with role and content.
rolerequiredstringRole of the message sender
"user""assistant"contentrequiredarrayString or array of content blocks
Response Format
{
"id": "chat_abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "llama-v3p1-8b-instruct",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I can see a beautiful sunset over the ocean with vibrant orange and pink hues in the sky."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 56,
"completion_tokens": 31,
"total_tokens": 87
}
}Asynchronous requests (v2)
Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.
- 1
POST /v2/llama-v3p1-8b-instructSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- A FAILED request is served as HTTP 422 — the body still carries the error detail.
- An unknown or expired request_id returns HTTP 404.
- Results are retained for 1 hour, then expire.
- Content / RAI blocks surface as FAILED, not a separate state.
- Track completion by polling the status endpoint.
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid message format or parameters
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out