Chat Completions
Simple conversation with the AI:- CLI
- Python SDK
- JavaScript SDK
Copy
gravixlayer chat --model "meta-llama/llama-3.1-8b-instruct" --system "You are a helpful assistant." --user "What is Python?"
Copy
Python is a high-level, interpreted programming language known for its simplicity and readability. It was created by Guido van Rossum and first released in 1991. Python is widely used for web development, data analysis, artificial intelligence, scientific computing, and automation.
Key features of Python include:
- Easy-to-read syntax
- Large standard library
- Cross-platform compatibility
- Strong community support
- Extensive third-party packages
Copy
import os
from gravixlayer import GravixLayer
client = GravixLayer()
completion = client.chat.completions.create(
model="meta-llama/llama-3.1-8b-instruct",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is Python?"}
]
)
print(completion.choices[0].message.content)
Copy
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer({
apiKey: process.env.GRAVIXLAYER_API_KEY,
});
const completion = await client.chat.completions.create({
model: "meta-llama/llama-3.1-8b-instruct",
messages: [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is Python?"}
]
});
console.log(completion.choices[0].message.content);
Text Completions
Simple text completion from a prompt:- CLI
- Python SDK
- JavaScript SDK
Copy
gravixlayer chat --mode completions --model "meta-llama/llama-3.1-8b-instruct" --prompt "The future of artificial intelligence is"
Copy
The future of artificial intelligence is bright and full of possibilities. AI will continue to revolutionize industries, enhance human capabilities, and solve complex global challenges. We can expect to see advances in machine learning, natural language processing, computer vision, and robotics that will transform how we work, learn, and live.
Copy
import os
from gravixlayer import GravixLayer
client = GravixLayer()
completion = client.completions.create(
model="meta-llama/llama-3.1-8b-instruct",
prompt="The future of artificial intelligence is",
max_tokens=100
)
print(completion.choices[0].text)
Copy
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer({
apiKey: process.env.GRAVIXLAYER_API_KEY,
});
const completion = await client.completions.create({
model: "meta-llama/llama-3.1-8b-instruct",
prompt: "The future of artificial intelligence is",
max_tokens: 100
});
console.log(completion.choices[0].text);

