# Together AI Integration via LowCodeAPI

**Last Updated**: January 27, 2025

## Overview
Together AI makes it easy to run, finetune, and train open source AI models with transparency and privacy.

**Categories:**
- {'id': 'ai-cloud', 'name': 'AI Cloud'}

## Base Endpoint
https://api.lowcodeapi.com/togetherai

**Important**: Always include the provider name in the URL path after `api.lowcodeapi.com/`

## Authentication
**Type:** TOKEN

**Official Documentation:** https://docs.together.ai/intro

## URL Format (Important)

LowCodeAPI supports two URL formats. **Always try the New Format first**, then fall back to Old Format if needed.

### New Format (Priority)
- Path parameters stay in the URL path
- Do NOT include path parameters as query parameters
- Example: `https://api.lowcodeapi.com/{provider}/resource/{id}?api_token=XXX`

### Old Format (Fallback)
- Path parameters become query parameters
- Example: `https://api.lowcodeapi.com/{provider}/resource/id?id={id}&api_token=XXX`

### Decision Flow for AI Agents
1. Always use **New Format** first - keep path parameters in the URL path
2. If you get a 404 or error, try **Old Format** with sanitized path
3. Log which format worked for future requests to this provider

## API Categories

## Common Endpoints

### Create Chat Completion

**Method:** POST
**LowCodeAPI Path:** /v1/chat/completions

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/chat/completions?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/chat/completions?api_token=YOUR_API_TOKEN

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| frequency_penalty | number |  |
| logprobs | boolean |  |
| max_tokens | number |  |
| messages | array |  |
| model | string |  |
| presence_penalty | number |  |
| repetition_penalty | number |  |
| response_format | object |  |
| safety_model | string |  |
| stop | array |  |
| stream | boolean |  |
| temperature | number |  |
| tool_choice | object |  |
| tools | array |  |
| top_k | number |  |
| top_logprobs | number |  |
| top_p | number |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/togetherai/v1/chat/completions?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/chat-completions

### Create Completion

**Method:** POST
**LowCodeAPI Path:** /v1/completions

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/completions?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/completions?api_token=YOUR_API_TOKEN

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| echo | boolean |  |
| frequency_penalty | number |  |
| logprobs | boolean |  |
| max_tokens | number |  |
| model | string |  |
| presence_penalty | number |  |
| prompt | string |  |
| repetition_penalty | number |  |
| safety_model | string |  |
| stop | array |  |
| stream | boolean |  |
| suffix | string |  |
| temperature | number |  |
| top_k | number |  |
| top_logprobs | number |  |
| top_p | number |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/togetherai/v1/completions?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/completions

### Create Image

**Method:** POST
**LowCodeAPI Path:** /v1/images/generations

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/images/generations?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/images/generations?api_token=YOUR_API_TOKEN

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| guidance_scale | number |  |
| model | string |  |
| n | number |  |
| negative_prompt | string |  |
| prompt | string |  |
| response_format | string |  |
| seed | number |  |
| size | string |  |
| steps | number |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/togetherai/v1/images/generations?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/images

### Create Embedding

**Method:** POST
**LowCodeAPI Path:** /v1/embeddings

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/embeddings?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/embeddings?api_token=YOUR_API_TOKEN

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| input | string |  |
| model | string |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/togetherai/v1/embeddings?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/embeddings

### List Models

**Method:** GET
**LowCodeAPI Path:** /v1/models

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/models?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/models?api_token=YOUR_API_TOKEN

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/togetherai/v1/models?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/models

### Create Fine-tune

**Method:** POST
**LowCodeAPI Path:** /v1/fine-tunes

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes?api_token=YOUR_API_TOKEN

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| hyperparameters | object |  |
| model | string |  |
| suffix | string |  |
| training_file | string |  |
| validation_file | string |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/togetherai/v1/fine-tunes?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/fine-tuning

### List Fine-tunes

**Method:** GET
**LowCodeAPI Path:** /v1/fine-tunes

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes?api_token=YOUR_API_TOKEN

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/togetherai/v1/fine-tunes?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/fine-tuning

### Retrieve Fine-tune

**Method:** GET
**LowCodeAPI Path:** /v1/fine-tunes/{fine_tune_id}

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes/{fine_tune_id}?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes/fine_tune_id?fine_tune_id={fine_tune_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| fine_tune_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/togetherai/v1/fine-tunes/{fine_tune_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/fine-tuning

### Cancel Fine-tune

**Method:** POST
**LowCodeAPI Path:** /v1/fine-tunes/{fine_tune_id}/cancel

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes/{fine_tune_id}/cancel?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes/fine_tune_id/cancel?fine_tune_id={fine_tune_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| fine_tune_id | string |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/togetherai/v1/fine-tunes/{fine_tune_id}/cancel?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/fine-tuning

### List Fine-tune Events

**Method:** GET
**LowCodeAPI Path:** /v1/fine-tunes/{fine_tune_id}/events

**New Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes/{fine_tune_id}/events?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/togetherai/v1/fine-tunes/fine_tune_id/events?fine_tune_id={fine_tune_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| fine_tune_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/togetherai/v1/fine-tunes/{fine_tune_id}/events?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.together.ai/reference/fine-tuning


## Usage Examples

### Example 1: Basic Chat Completion

Creating a simple text completion or chat message:

```bash
# Create a chat completion - no path parameters needed
curl -X POST "https://api.lowcodeapi.com/togetherai/v1/chat/completions?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-name",
    "messages": [
      {"role": "user", "content": "Hello, how can you help me?"}
    ]
  }'

# Response includes generated content
```

### Example 2: Text Generation with Path Parameters

Generating text with specific model settings:

```bash
# Generate content using a specific model
curl -X POST "https://api.lowcodeapi.com/togetherai/v1/models/generate?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Write a short poem about technology",
    "max_tokens": 100
  }'

# Or if the provider uses model in the path:
curl -X POST "https://api.lowcodeapi.com/togetherai/v1/models/{MODEL_ID}:generateContent?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "Write a short story"}]}]
  }'
```

### Example 3: List Available Models

```bash
# Get list of available models
curl -X GET "https://api.lowcodeapi.com/togetherai/v1/models?api_token=YOUR_API_TOKEN"
```

## Error Handling

LowCodeAPI returns standard HTTP status codes. Common errors:

| Status Code | Description |
|-------------|-------------|
| 200 | Success - Request completed successfully |
| 400 | Bad Request - Invalid parameters or request body |
| 401 | Unauthorized - Invalid or missing API token |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Endpoint or resource doesn't exist |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Server Error - Provider API error |

All error responses include error details:

```json
{
  "data": {
    "error": {
      "message": "Error description",
      "code": "ERROR_CODE"
    }
  }
}
```

## Complete Endpoint Reference

| Endpoint | Method | Category |
|----------|--------|----------|
| Create Chat Completion | POST | Chat |
| Create Completion | POST | Completions |
| Create Image | POST | Images |
| Create Embedding | POST | Embeddings |
| List Models | GET | Models |
| Create Fine-tune | POST | Fine-tuning |
| List Fine-tunes | GET | Fine-tuning |
| Retrieve Fine-tune | GET | Fine-tuning |
| Cancel Fine-tune | POST | Fine-tuning |
| List Fine-tune Events | GET | Fine-tuning |
| List Files | GET | Files |
| Upload File | POST | Files |
| Retrieve File | GET | Files |
| Retrieve File Content | GET | Files |
| Delete File | DELETE | Files |
| Create Batch | POST | Batch |
| List Batches | GET | Batch |
| Retrieve Batch | GET | Batch |
| Cancel Batch | POST | Batch |
| Create Dedicated Endpoint | POST | Endpoints |
| List Dedicated Endpoints | GET | Endpoints |
| Retrieve Dedicated Endpoint | GET | Endpoints |
| Update Dedicated Endpoint | PATCH | Endpoints |
| Delete Dedicated Endpoint | DELETE | Endpoints |

## API Definition Endpoints

You can fetch the complete API specification for this provider:

**New Format (OpenAPI spec):**
```bash
curl 'https://backend.lowcodeapi.com/togetherai/openapi'
```

**Old Format (API definition):**
```bash
curl 'https://backend.lowcodeapi.com/togetherai/definition'
```

## Response Format

All responses are wrapped in a `data` key:

```json
{
  "data": {
    // Actual response from provider (object or array)
  }
}
```