# Date and time

Give a model the current date and time, in the time zone you choose.

1. [What it does](#1-what-it-does).
2. [Name it in `tools`](#2-name-it-in-tools).
3. [Choose the time zone](#3-choose-the-time-zone).
4. [Read what it bills on](#4-read-what-it-bills-on).

This page is one helper. The list of helpers, and how the charge adds up, sit in [Helpers](/docs/helpers).

## 1. What it does

A model knows nothing of today. When a question needs the date, such as scheduling, "this week" or a deadline, the model asks the helper, reads the date and the time, and goes on.

| | |
|---|---|
| Type | `opendunes:datetime` |
| Routes | `/v1/chat/completions`, `/v1/responses` and `/v1/messages` |
| A step | one call |
| Steps | at most 30 a request |
| Bills on | tokens only |

## 2. Name it in `tools`

Souk Bot tells a shopkeeper how many days are left in the month. The sample asks for the time in Algiers and prints the answer and the charge.

```python
import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
ADDRESS = "https://opendunes.com/v1/chat/completions"
MODEL = "anthropic/claude-sonnet-4.5"
PROMPT = "How many days are left until the end of this month?"

body = {
    "model": MODEL,
    "messages": [{"role": "user", "content": PROMPT}],
    "tools": [
        {
            "type": "opendunes:datetime",
            "parameters": {"timezone": "Africa/Algiers"},
        }
    ],
    "max_tool_calls": 2,
}
request = urllib.request.Request(
    ADDRESS,
    data=json.dumps(body).encode(),
    headers={
        "Authorization": "Bearer " + API_KEY,
        "Content-Type": "application/json",
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

print(answer["choices"][0]["message"]["content"])
print(answer["usage"]["cost"])
```

```javascript
const API_KEY = process.env.OPENDUNES_API_KEY;
const ADDRESS = "https://opendunes.com/v1/chat/completions";
const MODEL = "anthropic/claude-sonnet-4.5";
const PROMPT = "How many days are left until the end of this month?";

const response = await fetch(ADDRESS, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: MODEL,
    messages: [{ role: "user", content: PROMPT }],
    tools: [
      {
        type: "opendunes:datetime",
        parameters: { timezone: "Africa/Algiers" },
      },
    ],
    max_tool_calls: 2,
  }),
});
const answer = await response.json();

console.log(answer.choices[0].message.content);
console.log(answer.usage.cost);
```

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

const (
	address = "https://opendunes.com/v1/chat/completions"
	model   = "anthropic/claude-sonnet-4.5"
	prompt  = "How many days are left until the end of this month?"
)

func main() {
	apiKey := os.Getenv("OPENDUNES_API_KEY")
	body, err := json.Marshal(map[string]any{
		"model": model,
		"messages": []map[string]string{
			{"role": "user", "content": prompt},
		},
		"tools": []map[string]any{
			{
				"type":       "opendunes:datetime",
				"parameters": map[string]string{"timezone": "Africa/Algiers"},
			},
		},
		"max_tool_calls": 2,
	})
	if err != nil {
		panic(err)
	}
	req, err := http.NewRequest("POST", address, bytes.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+apiKey)
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	var answer struct {
		Choices []struct {
			Message struct {
				Content string `json:"content"`
			} `json:"message"`
		} `json:"choices"`
		Usage struct {
			Cost json.Number `json:"cost"`
		} `json:"usage"`
	}
	if err := json.NewDecoder(res.Body).Decode(&answer); err != nil {
		panic(err)
	}
	fmt.Println(answer.Choices[0].Message.Content)
	fmt.Println(answer.Usage.Cost)
}
```

```bash cURL
ADDRESS="https://opendunes.com/v1/chat/completions"
MODEL="anthropic/claude-sonnet-4.5"
PROMPT="How many days are left until the end of this month?"

curl "$ADDRESS" \
  -H "Authorization: Bearer $OPENDUNES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$MODEL"'",
    "messages": [
      {
        "role": "user",
        "content": "'"$PROMPT"'"
      }
    ],
    "tools": [
      {
        "type": "opendunes:datetime",
        "parameters": {
          "timezone": "Africa/Algiers"
        }
      }
    ],
    "max_tool_calls": 2
  }'
```

The answer is a `200`. Name the helper by its type, `opendunes:datetime`; any other spelling of the type is a `400`.

## 3. Choose the time zone

Put this in the helper's `parameters`.

| Parameter | Does |
|---|---|
| `timezone` | an IANA time zone name, such as `Africa/Algiers`; left out, `UTC` |

Pair the helper with [Web search](/docs/web-search) so a question about "this week" is searched with the right date.

## 4. Read what it bills on

No charge beyond the model's tokens. The date the helper returns is read as input, a few tokens, and the call itself adds no fee. `usage.cost` carries the whole of it.

Before the model starts, OpenDunes holds money from your wallet for the words and the answer. A call costs no money of its own, so the hold sets no step limit lower than yours: a request runs at most 30 steps, or the `max_tool_calls` you name. The helper runs no other model and no sandbox, so it has no spend cap.

<div class="dont">
<p>Don't paste today's date into every prompt by hand. A date typed into a stored prompt goes stale.</p>
</div>

<div class="do">
<p>Name the helper and set <code>timezone</code> to your customers' own zone, so "today" means their today.</p>
</div>
