initialize
This commit is contained in:
59
README.md
Normal file
59
README.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# x-ai SDK
|
||||
|
||||
A simple Luau SDK for the x.ai API.
|
||||
|
||||
## Installation
|
||||
|
||||
Install Rokit. Then install Lune like so:
|
||||
|
||||
```
|
||||
rokit install
|
||||
```
|
||||
|
||||
Then require the SDK in your Luau code.
|
||||
|
||||
## Usage
|
||||
|
||||
First, get your API key from [x.ai](https://x.ai).
|
||||
|
||||
Create a client instance:
|
||||
|
||||
```luau
|
||||
local xai = require("./src/init")
|
||||
|
||||
local client = xai.create("your-api-key-here")
|
||||
```
|
||||
|
||||
Make a chat completion request:
|
||||
|
||||
```luau
|
||||
local response = client:responses({
|
||||
model = "grok-4",
|
||||
messages = {
|
||||
{ role = "user", content = "Hello, Grok!" }
|
||||
}
|
||||
})
|
||||
|
||||
print(response.choices[1].message.content)
|
||||
```
|
||||
|
||||
For backward compatibility, you can also use the static method:
|
||||
|
||||
```luau
|
||||
local response = xai.responses("your-api-key", request)
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
The module exports several types for requests and responses:
|
||||
|
||||
- `model`: Available models like 'grok-4', etc.
|
||||
- `message`: Structure for chat messages.
|
||||
- `CompletionsResponse`: The response from the API.
|
||||
- `CompletionsRequest`: The request structure.
|
||||
|
||||
Refer to `src/init.luau` for full type definitions.
|
||||
|
||||
## License
|
||||
MIT.
|
||||
See `LICENSE` for details.
|
||||
Reference in New Issue
Block a user