Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api-reference/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@
}
],
"description": "Controls which tool is called by the model."
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Optional tags to categorize and label the request. Useful for filtering and grouping requests in analytics and logs. Can also be sent via the `x-edgee-tags` header as a comma-separated string."
}
}
},
Expand Down
25 changes: 25 additions & 0 deletions integrations/langchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,31 @@ for chunk in llm.stream("Tell me a long story"):
print(chunk.content, end="", flush=True)
```

### Tags

You can add tags to your requests for analytics and filtering using the `default_headers` parameter:

```python
from langchain_openai import ChatOpenAI
import os

llm = ChatOpenAI(
base_url="https://api.edgee.ai/v1",
api_key=os.getenv("API_KEY"),
model="mistral-small",
default_headers={
"x-edgee-tags": "production,user-123,langchain",
},
)

# All requests from this client will include these tags
response = llm.invoke("What is LangChain?")
```

<Tip>
Tags are comma-separated strings in the header. They help you categorize and filter requests in Edgee's analytics dashboard.
</Tip>

## Authentication

Edgee uses standard Bearer token authentication. Set your API key as an environment variable:
Expand Down
14 changes: 14 additions & 0 deletions sdk/go/send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ When `input` is an `InputObject`, you have full control over the conversation:
| `Messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `[]Message` | Array of conversation messages |
| `Tools` | `[]Tool` | Array of function tools available to the model |
| `ToolChoice` | `any` | Controls which tool (if any) the model should call. Can be `string` (`"auto"`, `"none"`) or `map[string]interface{}`. See [Tools documentation](/sdk/go/tools) for details |
| `Tags` | `[]string` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

**Example with InputObject:**

Expand All @@ -63,6 +64,19 @@ fmt.Println(response.Text())
// "2+2 equals 4."
```

**Example with Tags:**

```go
input := edgee.InputObject{
Messages: []edgee.Message{
{Role: "user", Content: "Summarize this article"},
},
Tags: []string{"summarization", "production", "user-123"},
}

response, err := client.Send("gpt-4o", input)
```

#### Map Input

You can also use a `map[string]interface{}` for dynamic input:
Expand Down
1 change: 1 addition & 0 deletions sdk/go/stream.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ When `input` is an `InputObject` or `map[string]interface{}`, you have full cont
| `Messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `[]Message` | Array of conversation messages |
| `Tools` | `[]Tool` | Array of function tools available to the model |
| `ToolChoice` | `any` | Controls which tool (if any) the model should call. See [Tools documentation](/sdk/go/tools) for details |
| `Tags` | `[]string` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

For details about `Message` type, see the [Send Method documentation](/sdk/go/send#message-object).
For details about `Tool` and `ToolChoice` types, see the [Tools documentation](/sdk/go/tools).
Expand Down
57 changes: 57 additions & 0 deletions sdk/openai/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,63 @@ else:

</CodeGroup>

### Tags

You can add tags to your requests for analytics and filtering using the `x-edgee-tags` header:

<CodeGroup>

```typescript title="TypeScript"
import OpenAI from "openai";

const openai = new OpenAI({
baseURL: "https://api.edgee.ai/v1",
apiKey: process.env.EDGEE_API_KEY,
defaultHeaders: {
"x-edgee-tags": "production,user-123,summarization",
},
});

// All requests will include these tags
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
{ role: "user", content: "What is the capital of France?" }
],
});
```

```python title="Python"
from openai import OpenAI
from os import getenv

# Tags applied to all requests via default headers
client = OpenAI(
base_url="https://api.edgee.ai/v1",
api_key=getenv("EDGEE_API_KEY"),
default_headers={
"x-edgee-tags": "production,user-123,summarization",
},
)

# Or per-request using extra_headers
completion = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "What is the capital of France?"},
],
extra_headers={
"x-edgee-tags": "one-off-tag,experiment",
},
)
```

</CodeGroup>

<Tip>
Tags are comma-separated strings in the header. They help you categorize and filter requests in Edgee's analytics dashboard.
</Tip>

### Streaming Responses

Edgee supports streaming responses for real-time token delivery:
Expand Down
15 changes: 15 additions & 0 deletions sdk/python/send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ When `input` is an `InputObject` or dictionary, you have full control over the c
| `messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `list[dict]` | Array of conversation messages |
| `tools` | `list[dict] \| None` | Array of function tools available to the model |
| `tool_choice` | `str \| dict \| None` | Controls which tool (if any) the model should call. See [Tools documentation](/sdk/python/tools) for details |
| `tags` | `list[str] \| None` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

**Example with Dictionary Input:**

Expand All @@ -58,6 +59,20 @@ print(response.text)
# "2+2 equals 4."
```

**Example with Tags:**

```python
response = edgee.send(
model="gpt-4o",
input={
"messages": [
{"role": "user", "content": "Summarize this article"}
],
"tags": ["summarization", "production", "user-123"]
}
)
```

### Message Object

Each message in the `messages` array has the following structure:
Expand Down
1 change: 1 addition & 0 deletions sdk/python/stream.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ When `input` is an `InputObject` or dictionary, you have full control over the c
| `messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `list[dict]` | Array of conversation messages |
| `tools` | `list[dict] \| None` | Array of function tools available to the model |
| `tool_choice` | `str \| dict \| None` | Controls which tool (if any) the model should call. See [Tools documentation](/sdk/python/tools) for details |
| `tags` | `list[str] \| None` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

For details about `Message` type, see the [Send Method documentation](/sdk/python/send#message-object).
For details about `Tool` and `ToolChoice` types, see the [Tools documentation](/sdk/python/tools).
Expand Down
17 changes: 17 additions & 0 deletions sdk/rust/send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ When `input` is an `InputObject`, you have full control over the conversation:
| `messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `Vec<Message>` | Array of conversation messages |
| `tools` | `Option<Vec<Tool>>` | Array of function tools available to the model |
| `tool_choice` | `Option<serde_json::Value>` | Controls which tool (if any) the model should call. See [Tools documentation](/sdk/rust/tools) for details |
| `tags` | `Option<Vec<String>>` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

**Example with InputObject:**

Expand All @@ -71,6 +72,22 @@ println!("{}", response.text().unwrap_or(""));
// "2+2 equals 4."
```

**Example with Tags:**

```rust
use edgee::{Message, InputObject};

let input = InputObject::new(vec![
Message::user("Summarize this article")
]).with_tags(vec![
"summarization".to_string(),
"production".to_string(),
"user-123".to_string()
]);

let response = client.send("gpt-4o", input).await?;
```

### Message Object

Each message in the `messages` array is created using `Message` constructors:
Expand Down
1 change: 1 addition & 0 deletions sdk/rust/stream.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ When `input` is a `Vec<Message>` or `InputObject`, you have full control over th
| `messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `Vec<Message>` | Array of conversation messages |
| `tools` | `Option<Vec<Tool>>` | Array of function tools available to the model |
| `tool_choice` | `Option<serde_json::Value>` | Controls which tool (if any) the model should call. See [Tools documentation](/sdk/rust/tools) for details |
| `tags` | `Option<Vec<String>>` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

For details about `Message` type, see the [Send Method documentation](/sdk/rust/send#message-object).
For details about `Tool` and `ToolChoice` types, see the [Tools documentation](/sdk/rust/tools).
Expand Down
15 changes: 15 additions & 0 deletions sdk/typescript/send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ When `input` is an `InputObject`, you have full control over the conversation:
| `messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `Message[]` | Array of conversation messages |
| `tools` | `Tool[]` | Array of function tools available to the model |
| `tool_choice` | `ToolChoice` | Controls which tool (if any) the model should call. See [Tools documentation](/sdk/typescript/tools) for details |
| `tags` | `string[]` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

**Example with InputObject:**

Expand All @@ -61,6 +62,20 @@ console.log(response.text);
// "2+2 equals 4."
```

**Example with Tags:**

```typescript
const response = await edgee.send({
model: 'gpt-4o',
input: {
messages: [
{ role: 'user', content: 'Summarize this article' }
],
tags: ['summarization', 'production', 'user-123']
}
});
```

### Message Object

Each message in the `messages` array has the following structure:
Expand Down
1 change: 1 addition & 0 deletions sdk/typescript/stream.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ When `input` is an `InputObject`, you have full control over the conversation:
| `messages` <Tooltip headline="Required" tip="The field is required."><Icon icon="asterisk" size={15} color="#8924A6" /></Tooltip> | `Message[]` | Array of conversation messages |
| `tools` | `Tool[]` | Array of function tools available to the model |
| `tool_choice` | `ToolChoice` | Controls which tool (if any) the model should call. See [Tools documentation](/sdk/typescript/tools) for details |
| `tags` | `string[]` | Optional tags to categorize and label the request for analytics and filtering. Can also be sent via the `x-edgee-tags` header (comma-separated) |

For details about `Message` type, see the [Send Method documentation](/sdk/typescript/send#message-object).
For details about `Tool` and `ToolChoice` types, see the [Tools documentation](/sdk/typescript/tools).
Expand Down